logo头像

技术引领生活!

利用openssl自己发布ssl证书

本文于660天之前发表,文中内容可能已经过时。

前几天编写ftp服务器时如果采用SSL加密的话需要证书于是就抄袭了下以记录

生成步骤

  1. 创建服务器证书密钥文件 server.key:
    1
    openssl genrsa -des3 -out server.key 2048
    输入密码,确认密码,自己随便定义,但是要记住,后面会用到。
  1. 创建服务器证书的申请文件 server.csr
    1
    openssl req -new -key server.key -out server.csr
    输出内容为:
1
2
3
4
5
6
7
8
9
10
11
12
Enter pass phrase for root.key: ← 输入前面创建的密码
Country Name (2 letter code) [AU]:CN ← 国家代号,中国输入CN
State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音
Locality Name (eg, city) []:BeiJing ← 市的全名,拼音
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名
Organizational Unit Name (eg, section) []: ← 可以不输入
Common Name (eg, YOUR name) []: ← 输入域名,如:iot.conet.com
Email Address []:admin@mycompany.com ← 电子邮箱,可随意填
Please enter the followingextraattributes
to be sent with your certificate request
A challenge password []: ← 可以不输入
An optional company name []: ← 可以不输入
  1. 备份一份服务器密钥文件

    1
    cp server.key server.key.org
  2. 去除文件口令

    1
    openssl rsa -in server.key.org -out server.key
  3. 生成证书文件server.crt

    1
    openssl x509 -req -days 18250 -in server.csr -signkey server.key -out server.crt

    都自己说了算了,就先来个五十年的吧,哈哈

更多

  • 触类旁通下应该也是可以用到自定义的HTTPS加密上
  • Windows 环境的openssl软件在安装了git后就有了,Linux下嘛随地都是

参(cao)考(xi)链接

Nginx https证书生成

支付宝打赏 微信打赏

您的支持是我前行的动力!