制作SSL自签证书

以NGINX证书为例,制作自签证书

SSL自签证书的制作

  1. 生成私钥(Key):使用openssl生成私钥文件(.key文件),执行以下命令:
$openssl genrsa -out yourdomain.key 2048
  1. 生成证书签名请求(CSR):使用私钥生成证书签名请求文件(.csr文件),执行以下命令:
$openssl req -new -key yourdomain.key -out yourdomain.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:CN
State or Province Name (full name) []:Shanghai
Locality Name (eg, city) []:Shanghai
Organization Name (eg, company) []:OP
Organizational Unit Name (eg, section) []:OP
Common Name (eg, fully qualified host name) []:*.et
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
  1. 生成自签证书:使用私钥和CSR文件生成自签证书(.crt文件),执行以下命令:
$openssl x509 -req -days  36500 -in op.em.csr -signkey op.em.key -out yourdomain.crt

这将生成一个有效期为36500天的自签SSL证书。

  1. 配置NGINX使用SSL证书:打开NGINX配置文件,在需要使用SSL的server块中添加以下配置:
server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /path/to/yourdomain.crt;
    ssl_certificate_key /path/to/yourdomain.key;

    # 其他SSL配置项
}
  1. 重启NGINX服务:完成配置后,重新加载或重启NGINX服务使更改生效
  2. 验证:
    在这里插入图片描述
  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值