假设我们要在我们的局域网内的新服务器/主机上设置自签名证书,在这种情况下,Let's Encrypt不是我们的选择,例如FRITZ!Box,域名:fritz.box,https://fritz.box,IPv4:192.168.1.1
1.1 生成CA的私钥
openssl genrsa -aes256 -out patrickca.key 4096
关于-aes128或-aes256:https://security.stackexchange.com/q/14068
1.2 生成CA证书(根证书)
openssl req -new -key patrickca.key -x509 -out patrickca.crt -days 3650
2. 创建您的域名/服务器证书请求
openssl req -new -nodes -newkey rsa:4096 -keyout fritzbox.key -out fritzbox.req -batch -subj "/C=DE/ST=Hamburg/L=Hamburg/O=Patrick CA/OU=router/CN=fritz.box" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:fritz.box,IP:192.168.1.1"))
3. 签署证书请求
openssl x509 -req -in fritzbox.req -CA patrickca.crt -CAkey patrickca.key -CAcreateserial -out fritzbox.crt -days 3650 -sha256 -extfile <(printf "subjectAltName=DNS:fritz.box,IP:192.168.1.1")
4. 构建证书链文件(您可能需要在组织过程中添加一个额外的中间证书)
cat fritzbox.key > fritzboxchain.pem
cat fritzbox.crt >> fritzboxchain.pem
cat patrickca.crt >> fritzboxchain.pem
如果这只是一个示例,您将把此文件导入到您的FRITZ!Box中。
5. Firefox和Chrome中的其他步骤(我目前不使用其他浏览器,我的组织中也没有其他人使用)
当您的浏览器显示有关https证书的警告消息时,您当然希望确认自己知道自己在做什么。
您可能希望将其设置为永久异常情况。
但请注意:请将第1.2步骤的CA证书导入为受信任的CA(在05/2020年,对于Firefox,设置CN=应该足够了;对于Chrome,如果它仍然无法接受您的自签名证书,则可能会出现SAN问题)。