Skip to content

Instantly share code, notes, and snippets.

@Gardelll
Created November 1, 2020 07:51
Show Gist options
  • Save Gardelll/e8078274abe32f8130fd25df17de59ee to your computer and use it in GitHub Desktop.
Save Gardelll/e8078274abe32f8130fd25df17de59ee to your computer and use it in GitHub Desktop.
生成自签名RSA证书
openssl genrsa 2048 > ca-key.pem # CA 私钥
openssl req -new -x509 -nodes -days 36500 -key ca-key.pem -out ca-cert.pem # CA 证书
openssl req -newkey rsa:2048 -days 36500 -nodes -keyout server-key.pem -out server-req.pem # 服务器私钥
openssl rsa -in server-key.pem -out server-key.rsa # 转换为 RSA 格式
openssl x509 -req -in server-req.pem -days 36500 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem # 服务器证书
openssl verify -CAfile ca-cert.pem server-cert.pem # 验证
openssl req -newkey rsa:2048 -days 36500 -nodes -keyout client-key.pem -out client-req.pem # 客户端私钥
openssl rsa -in client-key.pem -out client-key.rsa # 转换为 RSA 格式
openssl x509 -req -in client-req.pem -days 36500 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem # 客户端证书
openssl verify -CAfile ca-cert.pem client-cert.pem # 验证
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment