zoukankan      html  css  js  c++  java
  • Openssl生成证书三板斧

    证书创建三步曲:

    一、密钥文件

    二、请求文

    三、根证书签名

    最后看需要是否合并证书文件

    1. 创立根证书密钥文件(自己做CA)root.key:

    [kk@test ~]$ openssl genrsa -des3 -out root.key
    Generating RSA private key, 512 bit long modulus
    ……………..++++++++++++
    ..++++++++++++
    e is 65537 (0×10001)
    Enter pass phrase for root.key: ← 输入一个新密码
    Verifying – Enter pass phrase for root.key: ← 重新输入一遍密码

    2. 创立根证书的申请文件root.csr:
    [kk@test ~]$ 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 ‘.whflsc.com’, 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:
    [kk@test ~]$ 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:
    [kk@test ~]$ openssl genrsa -out server.key 2048
    Generating RSA private key, 2048 bit long modulus
    ….+++
    …………………………………………..+++
    e is 65537 (0×10001)

    5.创立服务器证书的申请文件server.csr:
    [kk@test ~]$ openssl req -new -key server.key -out server.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) [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) []:om ← 服务器主机名,若填写不准确,博览器会报告证书无效,但并不波及利用
    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 []: ← 能够不输入

    6. 创立自目前日期起管用期为期两年的服务器证书server.crt:
    [kk@test ~]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in server.csr -out server.crt
    Signature ok
    subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=om/emailAddress=admin@mycompany.com
    Getting CA Private Key
    Enter pass phrase for root.key: ← 输入前面创立的密码

    7. 将server.crt和书密钥文件server.key并合成证书安装包server.pfx
    [kk@test ~]$ openssl pkcs12 -export -in server.crt -inkey server.key -out server.pfx
    Enter pass phrase for server.key: ← 输入上面创立的密码
    Enter Export Password: ← 输入一个新的密码,用作客户端证书的防御密码,在客户端安装证书时必需输入此密码
    Verifying – Enter Export Password: ← 确认密码

  • 相关阅读:
    Java监听器Listener使用详解
    浮点数运算
    变量
    java For 循环 运行顺序
    java ++运算
    一些硬件厂商的MAC号
    c# 双问号运算
    SQL Server 触发器
    微软企业库Microsoft Enterprise Library的相关文章链接
    关于ligerUi的ligertree的初始化默认选中指定项目的方法
  • 原文地址:https://www.cnblogs.com/cool-fire/p/4469345.html
Copyright © 2011-2022 走看看