使用OpenSSL生成自签名SSL/TLS证书和私钥

前提: 系统安装了OpenSSL;

系统:windows、linux都可;

1 生成私钥

创建一个名为 server.key 的私钥文件,并使用 RSA 算法生成一个 2048 位的密钥。

openssl genrsa -out server.key 2048
2 生成证书请求

在命令行中输入以下命令以生成证书请求(CSR)

openssl req -new -key server.key -out server.csr
3 生成自签名证书

创建一个名为 server.crt 的自签名证书文件,并使用私钥文件对其进行签名。

openssl x509 -req -in server.csr -signkey server.key -out server.crt
4 注意项
  1. 当证书用于配置nginxSSL 证书时,通过浏览器访问 https 可能会有不安全的提示;
  2. 通过postman等工具访问 https 时,需要在 postman 设置中将 SSL certificate verification 设置为 OFF
GitHub 加速计划 / ope / openssl
24
1
下载
传输层安全性/安全套接层及其加密库
最近提交(Master分支:4 个月前 )
75bc132d Current preforms the following operations 1) Generates arbitrary key pairs 2) Generates key pairs with parameters (both correct and incorrect) based on fuzzer input buffer 3) Exports and re-imports keys, confirming validity 4) Preforms Sign and Verify operations with optional parameters based on fuzzer input buffer Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/26708) 9 天前
0e436524 Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Paul Dale <ppzgs1@gmail.com> (Merged from https://github.com/openssl/openssl/pull/26701) 9 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐