From a32eed44746b3ca90da41b24f9c2b09d4132f572 Mon Sep 17 00:00:00 2001 From: baiyfcu <87684855@qq.com> Date: Tue, 16 Sep 2025 17:27:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E5=A4=9A=E5=9F=9F=E5=90=8D=E6=88=96=E5=A4=9A?= =?UTF-8?q?ip=E6=83=85=E5=86=B5=E4=B8=8B=E8=AF=81=E4=B9=A6=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 生成SSL自签名证书并测试.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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