主要是自颁发证书,一般用于测试或内部使用,用于公网使用会被浏览器阻止提醒。

https证书一键生成脚本httpsmake.sh

#!/bin/sh
# create self-signed server certificate:
read -p "Enter your domain [www.example.com]: " DOMAIN
echo "Create server key..."
openssl genrsa -des3 -out $DOMAIN.key 1024
echo "Create server certificate signing request..."
SUBJECT="/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=$DOMAIN"
openssl req -new -subj $SUBJECT -key $DOMAIN.key -out $DOMAIN.csr
echo "Remove password..."
mv $DOMAIN.key $DOMAIN.origin.key
openssl rsa -in $DOMAIN.origin.key -out $DOMAIN.key
echo "Sign SSL certificate..."
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
echo "OK"

使用方式

[root@localhost]# sh httpsmake.sh 
Enter your domain [www.example.com]: www.test.com   
Create server key...
Generating RSA private key, 1024 bit long modulus
.....++++++
.......++++++
e is 65537 (0x10001)
Enter pass phrase for www.test.com.key:
Verifying - Enter pass phrase for www.test.com.key:
Create server certificate signing request...
Enter pass phrase for www.test.com.key:
Remove password...
Enter pass phrase for www.test.com.origin.key:
writing RSA key
Sign SSL certificate...
Signature ok
subject=/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=www.test.com
Getting Private key
OK
[root@localhost]# ll
总用量 20
-rw-r--r-- 1 root root 606 12月 16 09:19 httpsmake.sh
-rw-r--r-- 1 root root 879 12月 16 09:25 www.test.com.crt
-rw-r--r-- 1 root root 664 12月 16 09:25 www.test.com.csr
-rw-r--r-- 1 root root 887 12月 16 09:25 www.test.com.key
-rw-r--r-- 1 root root 963 12月 16 09:25 www.test.com.origin.key

脚本转载来自网上