标签:rsa cert bit serve 信任 info under bsd blank
vim ca.conf
内容如下
[ req ] default_bits = 4096 distinguished_name = req_distinguished_name [ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = CN stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = JiangSu localityName = Locality Name (eg, city) localityName_default = NanJing organizationName = Organization Name (eg, company) organizationName_default = Sheld commonName = Common Name (e.g. server FQDN or YOUR name) commonName_max = 64 commonName_default = Ted CA Test
openssl genrsa -out ca.key 4096
openssl req \
-new \
-sha256 \
-out ca.csr \
-key ca.key \
-config ca.conf
配置文件中已经有默认值了,shell交互时一路回车就行。
openssl x509 \
-req -days 3650 -in ca.csr -signkey ca.key -out ca.crt
vim server.conf
内容如下
[ req ] default_bits = 2048 distinguished_name = req_distinguished_name req_extensions = req_ext [ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = CN stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = JiangSu localityName = Locality Name (eg, city) localityName_default = NanJing organizationName = Organization Name (eg, company) organizationName_default = Sheld commonName = Common Name (e.g. server FQDN or YOUR name) commonName_max = 64 commonName_default = www.ted2018.com [ req_ext ] subjectAltName = @alt_names [alt_names] DNS.1 = www.ted-go.com DNS.2 = www.ted2018.com IP = 192.168.93.145
注意Chrome 58以后不再使用CN校验地址(就是就是浏览器地址栏URL中的那个地址host)了,而是使用SAN,注意配置里写对。
IE 11还是使用CN。
火狐还是有些问题,待排查。
openssl genrsa -out server.key 2048
openssl req \
-new \
-sha256 \
-out server.csr \
-key server.key \
-config server.conf
配置文件中已经有默认值了,shell交互时一路回车就行。
openssl x509 \
-req \
-days 3650 \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-in server.csr \
-out server.crt \
-extensions req_ext \
-extfile server.conf
Web服务器选用nginx(Windows),关键配置如下
server { listen 443 ssl; server_name localhost; root D:\websocketd-0.3.0-windows_amd64; ssl_certificate server.crt; ssl_certificate_key server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { index index.html index.htm; } }
把生成好的server.crt和server.key文件放在与nginx.conf同一目录下。
客户端机器,Windows系统本地测试,改下hosts以访问域名
C:\Windows\System32\drivers\etc\hosts
添加如下内容
127.0.0.1 www.ted2018.com
右键ca.crt安装,安装到“受信任的根证书颁发机构”(不然server.crt还是不受信任的)
Chrome访问“使用者可选名称”里面的几个地址都是OK的(地址栏显示“连接是安全的”)
配置Websocket SSL
想深入了解证书链,可参见以下链接
标签:rsa cert bit serve 信任 info under bsd blank
原文地址:https://www.cnblogs.com/nidey/p/9041960.html