Https自签名证书的生成

本文是由于需升级https的签名长度,做了以下记录
参考文档有:
https://blog.csdn.net/PZ0605/article/details/51955839
https://blog.csdn.net/xuplus/article/details/51613883

本人电脑为MacOS系统,使用自带的openssl生成自签名证书
参考以上两个链接,根据自身的情况做了一些小的修改:
macos的不经过CA的证书生成:参考第一个链接
1、在cmd终端输入:openssl进入openssl,接着运行以下步骤命令
2、genrsa -out private_key.pem 2048
3、pkcs8 -topk8 -inform PEM -in private_key.pem -outform PEM
4、rsa -in private_key.pem -pubout -out public_key.pem
5、req -new -out cert.csr -key private_key.pem
6、x509 -req -in cert.csr -out public_key.crt -signkey private_key.pem -days 3650

其中public_key.pem与cert.csr在项目中未使用,项目中在使用https调用时仅使用private_key.pem和public_key.crt,分别将文件中的内容作为参数秘钥key与证书cert。

macos的经过CA的证书生成:参考第二个链接
1、在cmd终端输入:openssl进入openssl,接着运行以下步骤命令
2、genrsa -out server.pem 2048
3、req -new -x509 -key server.pem -out ca.crt -days 3650
4、req -new -key server.pem -out server.csr
5、req -new -out cert3.pem -key server.pem
6、x509 -req -days 3650 -in cert3.pem -CA ca.crt -CAkey server.pem -CAcreateserial -out server.crt

其中项目中在使用https调用时仅使用server.pem与server.crt,分别将文件中的内容作为参数秘钥key与证书cert

这个链接是介绍了关于X509和genrsa的命令详解,这些都是在摸索过程中参考过的文档:
https://blog.csdn.net/abccheng/article/details/82697237
https://www.cnblogs.com/274914765qq/p/4665959.html

你可能感兴趣的:(https服务)