找到[ req ]段落在底下添加req_extentions = v3_req
找到[ v3_req ]段落,添加subjectAltName = @alt_names
添加一个段落
[ alt_names ]
DNS.1 = linzopi.vpn(web服务端域名,需要根据申请者的域名修改)
效果:
上面的命令执行完成后把subca1.csr发到根CA的/etc/pki/CA/newcerts目录里面
下面这个命令在根CA终端执行
openssl ca -in /etc/pki/CA/newcerts/subca1.csr -cert /etc/pki/CA/cacert.pem -keyfile /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/newcerts/cacert.pem -days 3650如果没问题newcerts目录里可以找到一个新的cacert.pem文件,传到子CA的/etc/pki/CA/里面.并且安装到Windows的"中间证书颁发机构"
WEB服务端 生成key和证书请求注意Common Name这里,要填写域名,否则浏览器会认为不安全!
mkdir ~/cert/ openssl genrsa -out ~/cert/linzopi.key 2048 openssl req -new -key ~/cert/linzopi.key -out ~/cert/linzopi.csr -subj /C=CN/ST=GD/O=LINZ/CN=linzopi.vpncsr传到子CA的/etc/pki/CA/newcerts目录里面
子CA:
openssl ca -in /etc/pki/CA/newcerts/linzopi.csr -out /etc/pki/CA/newcerts/linzopi.crt -days 365 -extensions v3_req得到linzopi.csr文件(虽然生成的时候文件后缀名设为crt实际上是pem格式,如果需要der格式,加-outform der参数),传回web服务端~/cert/目录.
Nginx配置 user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 1024; # multi_accept on; } http { server { listen 443; server_name linzopi.vpn; ssl on; ssl_certificate /root/cert/linzopi.crt; ssl_certificate_key /root/cert/linzopi.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; location / { root html; index index.html; } } } 最终客户端