diff --git a/生成SSL自签名证书并测试.md b/生成SSL自签名证书并测试.md index 166c890..c8ceebd 100644 --- a/生成SSL自签名证书并测试.md +++ b/生成SSL自签名证书并测试.md @@ -56,4 +56,38 @@ base64内容 base64内容 -----END CERTIFICATE----- ``` -如果不是-----BEGIN RSA PRIVATE KEY----- 可以重新开始第4部,将文件调换下顺序,重新合并 \ No newline at end of file +如果不是-----BEGIN RSA PRIVATE KEY----- 可以重新开始第4部,将文件调换下顺序,重新合并 + +# 7、证书包含多ip或域名情况 +## 创建服务器证书配置文件 server.conf +``` +[ req ] +distinguished_name = req_distinguished_name +req_extensions = req_ext + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +stateOrProvinceName = State or Province Name (full name) +localityName = Locality Name (eg, city) +organizationName = Organization Name (eg, company) +organizationalUnitName = Organizational Unit Name (eg, section) +commonName = Common Name (eg, fully qualified host name) +emailAddress = Email Address + +[ req_ext ] +subjectAltName = @alt_names + +[ alt_names ] +DNS.1 = localhost +DNS.2 = *.local +DNS.3 = wss.local +IP.1 = 192.168.1.10 +IP.2 = 192.168.1.11 +``` +## 命令顺序 +```bash +openssl genpkey -algorithm RSA -out server.key +openssl req -new -key server.key -out server.csr -config server.cnf +openssl x509 -req -in server.csr -signkey server.key -out server.crt -extensions req_ext -extfile openssl.cnf -days 36500 +cat server.key server.crt > ./ssl.pem +``` \ No newline at end of file