mac上使用openssl以两种方式生成自签名证书操作图解

参考资料

openssl命令详解


常规方式

  • 生成私钥(key文件)
    openssl genrsa -out client.key 4096
    mac上使用openssl以两种方式生成自签名证书操作图解
    mac上使用openssl以两种方式生成自签名证书操作图解

  • 生成签名请求(csr文件)
    openssl req -new -key client.key -out client.csr
    mac上使用openssl以两种方式生成自签名证书操作图解

  • 签发证书
    openssl x509 -req -days 365 -in client.csr -signkey client.key -out client.crt
    mac上使用openssl以两种方式生成自签名证书操作图解


一键生成自签名证书

openssl req -new -x509 -newkey rsa:4096 -keyout test.key -out test.crt
mac上使用openssl以两种方式生成自签名证书操作图解

tips
输入的密码必须大于等于4位。
Common Name可以输入:*.yourdomain.com,这种方式生成通配符域名证书。
证书文件crt中存储的是证书信息与公钥信息,key文件存储的是私钥信息,csr是申请证书所需要的中间文件。