网站证书ssl

方法一: https://www.sslforfree.com/ #DNS验证下载ssl证书 cat certificate.crt、ca_bundle.crt >> server.crt vi server.crt 没有换行符,第二个文件需要在第一个文件的下一行粘贴,否则报错,证书无法使用

cat private.key > server.key

2.ssl.conf listen 443 ssl; servername img.xxx.com;

方法二: #创建根证书 openssl genrsa -des3 -out root.key openssl req -new -key root.key -out root.csr openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt #-------------------- #创建服务器证书 openssl genrsa -des3 -out server.key 2048 #去掉密码 openssl rsa -in server.key -out server.key openssl req -new -key server.key -out server.csr openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in server.csr -out server.crt #server.key and server.crt #=====================

  1. 创建根证书密钥文件(自己做CA)root.key: openssl genrsa -des3 -out root.key

  2. 创建根证书的申请文件root.csr:

    openssl req -new -key root.key -out root.csr 输出内容为:

    [lenin@archer ~]$ openssl req -new -key root.key -out root.csr Enter pass phrase for root.key: ← 输入前面创建的密码 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) [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) []: ← 此时不输入 Email Address []:admin@mycompany.com ← 电子邮箱,可随意填

    Please enter the following ‘extra’ attributes to be sent with your certificate request A challenge password []: ← 可以不输入 An optional company name []: ← 可以不输入

  3. 创建一个自当前日期起为期十年的根证书root.crt:

    openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.req -out root.crt

输出内容为:

[lenin[@archer](https://my.oschina.net/archer) ~]$ openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./emailAddress=admin@mycompany.com
Getting Private key
Enter pass phrase for root.key: ← 输入前面创建的密码

#--------- 4. 创建服务器证书密钥server.key:

openssl genrsa –des3 -out server.key 2048

去除key文件口令的命令: openssl rsa -in server.key -out server.key

5.创建服务器证书的申请文件server.csr:

openssl req -new -key server.key -out server.csr

输出内容为:

[lenin[@archer](https://my.oschina.net/archer) ~]$ openssl req -new -key server.key -out server.req
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) [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) []:www.mycompany.com ← 服务器主机名,若填写不正确,浏览器会报告证书无效,但并不影响使用
Email Address []:admin@mycompany.com ← 电子邮箱,可随便填

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: ← 可以不输入
An optional company name []: ← 可以不输入
  1. 创建自当前日期起有效期为期两年的服务器证书server.crt:

    openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.csr -out server.crt

转载于:https://my.oschina.net/jk409/blog/1609471

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值