我自己搭建的 Nginx Web Server 想要提供 HTTPS 连接方式,但是觉得不想花钱去找知名 CA 证书中心 (e.g. AWS Certificate Manager) 购买证书。于是我想通过 Self-Signed 的方式来解决我的需求:
shellopenssl req \ -newkey rsa:2048 -nodes -keyout self-ca.key \ -x509 -days 365 -out self-ca.crt
shellopenssl req \ -newkey rsa:2048 -nodes -keyout nginx.key \ -out nginx.csr
shellopenssl x509 \ -req -in nginx.csr \ -out nginx.crt \ -CAcreateserial -days 365 \ -CA self-ca.crt -CAkey self-ca.key
经过了上面 3 个步奏后,你就得到了 self-ca.crt & self-ca.key ,以及由它签发出来的 nginx.crt & nginx.key 。 如何使用上面 4 个文件:首先将 nginx.crt & nginx.key 部署在 Nginx Web Server 上,然后将 self-ca.crt 发布给客户端即可。客户端就可以通过 self-ca.crt 与业务服务器建立 SSL/TLS 安全连接。
shellopenssl req -newkey rsa:4096 -nodes -keyout server.key -x509 -days 365 -out server.crt -subj "/C=CN/ST=st/L=l/O=o/OU=ou/CN=cn/emailAddress=xxx@xxx.com"
shellopenssl rand -base64 32
本文作者:菜鸟
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!