#DER编码查看 openssl req -noout -text -inform der -in my.csr
(5)PFX/P12 格式: predecessor of PKCS#12包含公钥和私钥的二进制格式证书,对于nginx来说是分开存放在不同文件中(相对安全),但Windows的IIS则将它们存在一个PFX文件中(因此这个文件包含了证书及私钥)为了提高安全性PFX格式证书通常会有一个提取密码,当您想提取任何东西的时候都需要输入该密码;
# (2) 创建CSR证书申请文件:Generate CSR openssl req -new -key ca.key -out ca.csr # Country Name (2 letter code) [XX]:CN #地区 # State or Province Name (full name) []:CN #省份 # Locality Name (eg, city) [Default City]:CQ #城市 # Organization Name (eg, company) [Default Company Ltd]:weiyigeek #组织名称 # Organizational Unit Name (eg, section) []:weiyigeek #单元名称 # Common Name (eg, your name or your servers hostname) []:weiyigeek.top #通用名称即网站域名 # Email Address []:test@qq.com # A challenge password []:weiyigeek #认证密码 # An optional company name []:
# Full Name: # URI:http://root-ca.wieyigeek.top/root-ca.crl
# X509v3 Extended Key Usage: # TLS Web Client Authentication, TLS Web Server Authentication # X509v3 Key Usage: critical # Certificate Sign, CRL Sign # X509v3 Name Constraints: # Permitted: # DNS:example.com # DNS:example.org # Excluded: # IP:0.0.0.0/0.0.0.0 # IP:0:0:0:0:0:0:0:0/0:0:0:0:0:0:0:0
# X509v3 Subject Key Identifier: # 4B:B7:11:BE:C3:61:01:5F:C4:57:CC:9C:CE:E4:3C:3D:A6:E7:7F:56 # Certificate is to be certified until Aug 18 06:55:58 2030 GMT (3650 days) # Sign the certificate? [y/n]:y # 1 out of 1 certificate requests certified, commit? [y/n]y # Write out database with 1 new entries # Data Base Updated
# (3) 如果要吊销证书,可以使用ca命令的-revoke开关,不过需要有一份你想吊销的证书的副本。不过因为所有的证书都存在certs/目录下所以只需要知道序列号即可。如果知道证书的可分辨名称,就可以在数据库里面查到它的序列号了。 # 选项 -crl_reason 可选参数值: unspecified、keyCompromise 、 CACompromise 、 affiliationChanged 、 superseded 、 cessationOfOperation 、certificateHold和removeFromCRL; $ openssl ca \ -config conf/root-ca.conf \ -revoke certs/serialnumber.pem \ -crl_reason keyCompromise # $ openssl ca -config conf/root-ca.conf -revoke certs/sub-ca.crt -crl_reason keyCompromise # Using configuration from conf/root-ca.conf # Enter pass phrase for /opt/cert/private/root-ca.key: # Revoking Certificate 3756C1BEBA880B330E06ACFE58FD8725. # Data Base Updated
# (2) 按照根CA的过程创建一个同样的目录结构,不过可以使用另外一个名称比如sub-ca。 # 根二级CA的证书请求文件与密钥生成 openssl req -new \ -config conf/sub-ca.conf \ -out sub/certs/sub-ca.csr \ -keyout sub/private/sub-ca.key # Generating a 4096 bit RSA private key # writing new private key to 'sub/private/sub-ca.key' # Enter PEM pass phrase: #pass -> weiyigeeksub
# (3) 使用根CA来签发证书,-extensions开关指向配置文件中的sub_ca_ext 从而使用二级CA所需要的扩展; $ openssl ca \ -config conf/root-ca.conf \ # 此处的特殊性采用根CA签发二级CA -in sub/certs/sub-ca.csr \ -out sub/certs/sub-ca.crt \ -extensions sub_ca_ext # Using configuration from conf/root-ca.conf # Enter pass phrase for /opt/cert/private/root-ca.key: weiyigeek # 检查请求是否与签名匹配 # Signature ok # Certificate: # Data: # Version: 3 (0x2) # Serial Number: # 37:56:c1:be:ba:88:0b:33:0e:06:ac:fe:58:fd:87:27 # Issuer: # countryName = CN # organizationName = WeiyiGeek # commonName = Root CA # Validity # Not Before: Aug 20 09:06:16 2020 GMT # Not After : Aug 18 09:06:16 2030 GMT # 证书包含二级CA (关键点) # Subject: # countryName = CN # organizationName = WeiyiGeek # commonName = Sub CA # Subject Public Key Info: # Public Key Algorithm: rsaEncryption # Public-Key: (4096 bit) # Modulus: # 00:b6:cc:db:86:9a:65:2d:f7:89:38:88:8d:52:9c: # ..... # 93:39:c1 # Exponent: 65537 (0x10001) # X509v3 extensions: # Authority Information Access: # CA Issuers - URI:http://root-ca.wieyigeek.top/root-ca.crt # OCSP - URI:http://ocsp.root-ca.wieyigeek.top:9080 # X509v3 Authority Key Identifier: # keyid:4B:B7:11:BE:C3:61:01:5F:C4:57:CC:9C:CE:E4:3C:3D:A6:E7:7F:56 # X509v3 Basic Constraints: critical # CA:TRUE, pathlen:0 # X509v3 CRL Distribution Points: # Full Name: # URI:http://root-ca.wieyigeek.top/root-ca.crl # X509v3 Extended Key Usage: # TLS Web Client Authentication, TLS Web Server Authentication # X509v3 Key Usage: critical # Certificate Sign, CRL Sign ..... # X509v3 Subject Key Identifier: # 2E:68:BB:4E:04:63:99:70:0F:FB:DC:D9:9C:C2:9B:D6:27:D7:97:86 # Certificate is to be certified until Aug 18 09:06:16 2030 GMT (3650 days) # 签署的证书? [y/n]:y #1 / 1的证书请求被认证,提交? [y/n]y # Write out database with 1 new entries | 写出有1个新条目的数据库 # Data Base Updated | 数据库更新
# (4) 使用ca命令的-gencrl开关给二级CA生成sub-ca.crl文件 $ sudo openssl ca -gencrl -config conf/sub-ca.conf -out sub/certs/sub-ca.crl # Enter pass phrase for /opt/cert/sub/private/sub-ca.key: weiyigeeksub
# (5)二级CA之OCSP响应程序的密钥和证书生成: # OCSP 密钥与证书请求文件生成 openssl req -new \ -newkey rsa:2048 \ -subj "/C=CN/O=WeiyiGeek/CN=OCSP Sub Responder" \ -keyout sub/private/sub-ocsp.key \ -out sub/certs/sub-ocsp.csr # writing new private key to 'sub/private/sub-ocsp.key' # Enter PEM pass phrase: # weiyigeeksubocsp # Verifying - Enter PEM pass phrase:
# 其次需要使用根CA签发一张证书,任然采用-extensions选择ocsp_ext以确保设置了OCSP签名所需要的扩展; # 在root-ca.conf 配置文件中设置键值对如default_crl_days = 365,证书的生命周期减少为365天; $ openssl ca \ -config conf/sub-ca.conf \ -in sub/certs/sub-ocsp.csr \ -out sub/certs/sub-ocsp.crt \ -extensions ocsp_ext \ -days 30 # Enter pass phrase for /opt/cert/sub/private/sub-ca.key: weiyigeeksub # Check that the request matches the signature # Signature ok # Certificate Details: # Certificate: # Data: # Version: 3 (0x2) # Serial Number: # 37:56:c1:be:ba:88:0b:33:0e:06:ac:fe:58:fd:87:2a # Issuer: # countryName = CN # organizationName = WeiyiGeek # commonName = Sub CA # Validity # Not Before: Aug 20 14:58:01 2020 GMT # Not After : Sep 19 14:58:01 2020 GMT # Subject: # countryName = CN # organizationName = WeiyiGeek # commonName = OCSP Sub Responder
# (4) 服务端/客户端证书请文件和密钥生成 # private key (此处采用私钥加密,在测试的时候可-nodes即禁止对私钥文件加密) openssl genrsa -des3 -out sub/private/server.key 2048 # weiyigeekserver openssl genrsa -des3 -out sub/private/client.key 2048 # weiyigeekclient # generate csr (需要注意Organization Name与CA机构CA certificate一致为WeiyiGeek) openssl req -new -key sub/private/server.key -out sub/certs/server.csr # ----- # Country Name (2 letter code) [XX]:CN # State or Province Name (full name) []:ChongQing # Locality Name (eg, city) [Default City]:CQ # Organization Name (eg, company) [Default Company Ltd]:WeiyiGeek # Organizational Unit Name (eg, section) []:weiyigeek # Common Name (eg, your name or your server's hostname) []:server.weiyigeek.top # Email Address []:master@weiyigeek.top openssl req -new -key sub/private/client.key -out sub/certs/client.csr # ----- # Country Name (2 letter code) [XX]:CN # State or Province Name (full name) []:ChongQing # Locality Name (eg, city) [Default City]:CQ # Organization Name (eg, company) [Default Company Ltd]:WeiyiGeek # Organizational Unit Name (eg, section) []:client # Common Name (eg, your name or your server's hostname) []:weiyigeek.top # Email Address []:master@weiyigeek.top
# (5) 二级CA操作之签发服务器证书,即-extension server_ext openssl ca \ -config conf/sub-ca.conf \ -in sub/certs/server.csr \ -out sub/certs/server.crt \ -extensions server_ext # Enter pass phrase for /opt/cert/sub/private/sub-ca.key: # Check that the request matches the signature # Certificate: # Data: # Version: 3 (0x2) # Serial Number: # 5e:75:c7:d6:4e:33:0f:03:58:d4:82:d3:94:75:03:46 # Issuer: # countryName = CN # organizationName = WeiyiGeek # commonName = Sub CA # Validity # Not Before: Aug 20 15:40:41 2020 GMT # Not After : Aug 20 15:40:41 2021 GMT # Subject: # countryName = CN # stateOrProvinceName = ChongQing # organizationName = WeiyiGeek # organizationalUnitName = weiyigeek # commonName = server.weiyigeek.top # emailAddress = master@weiyigeek.top # Subject Public Key Info: # Public Key Algorithm: rsaEncryption # Public-Key: (2048 bit) # Modulus: # 00:e6:17:73:d8:66:9c:08:b6:2d:99:66:0c:a5:a3: # ........ # 38:30:4e:c1:66:c2:cd:f3:b2:5e:2c:dd:17:3d:5b: # 04:6d # Exponent: 65537 (0x10001) # X509v3 extensions: # Authority Information Access: # CA Issuers - URI:http://sub-ca.wieyigeek.top/sub-ca.crt # OCSP - URI:http://ocsp.sub-ca.wieyigeek.top:9081 # Certificate Reponse 认证 # X509v3 Authority Key Identifier: # keyid:0E:1B:6D:AA:0E:D5:6E:E4:C4:85:D6:48:37:3F:18:1B:FF:4C:BC:08 # X509v3 Basic Constraints: critical # CA:FALSE # X509v3 CRL Distribution Points: # Full Name: # URI:http://sub-ca.wieyigeek.top/sub-ca.crl # X509v3 Extended Key Usage: # TLS Web Client Authentication, TLS Web Server Authentication # X509v3 Key Usage: critical # Digital Signature, Key Encipherment # X509v3 Subject Key Identifier: # 20:F4:A9:32:B3:05:57:B1:10:E5:F7:73:D2:DF:E1:8D:45:8C:1D:67
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!