Skip to content

Instantly share code, notes, and snippets.

@heimoshuiyu
Created April 16, 2021 07:13
Show Gist options
  • Save heimoshuiyu/f5a9b571e091ea16f5e4a268b3e672ce to your computer and use it in GitHub Desktop.
Save heimoshuiyu/f5a9b571e091ea16f5e4a268b3e672ce to your computer and use it in GitHub Desktop.
openssl 用例
# 生成私钥
openssl genrsa -out myselfsigned.key 2048
# 利用私钥生成自签名证书
openssl req -new -x509 -key myselfsigned.key -out myselfsigned.cer -days 36500
# 利用私钥生成自签名证书,直接指定CN
openssl req -new -x509 -key myselfsigned.key -out myselfsigned.cer -days 36500 -subj /CN="*.abc.com"
# 创建一个CA的私钥和CA的证书
openssl genrsa -out myCA.key 2048
openssl req -new -x509 -key myCA.key -out myCA.cer -days 36500
# 创建一个服务器的私钥并生成req请求文件
openssl genrsa -out server.key 2048
openssl req -new -out server.req -key server.key -subj /CN="*.abc.com"
# 通过CA签发该req请求,得到证书
openssl x509 -req -in server.req -out server.cer -CAkey myCA.key -CA myCA.cer -days 36500 -CAcreateserial -CAserial serial
# 作者:walkerwzy
# 链接:https://www.jianshu.com/p/253c57e8c08e
# 来源:简书
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment