大家好,又见面了,我是你们的朋友全栈君。
1.准备签发证书环境
运维主机 hdss-1-200.host.com上:
2.安装CFSSL
证书签发工具CFSSL:R1.2
cfssl下载地址 https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
cfssl-json下载地址 https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
cfssl-certinfo下载地址 https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
3. 下载到指定目录
[root@hdss-1-200 ~]# wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -O /usr/bin/cfssl
[root@hdss-1-200 ~]# wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -O /usr/bin/cfssl-json
[root@hdss-1-200 ~]# wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -O /usr/bin/cfssl-certinfo
4.查看文件并赋执行权限
[root@hdss-1-200 bin]# ls -lrt cf*
-rw-r--r-- 1 root root 2277873 Feb 8 12:01 cfssl-json
-rw-r--r-- 1 root root 6595195 Feb 8 12:01 cfssl-certinfo
-rw-r--r-- 1 root root 10376657 Feb 8 12:01 cfssl
[root@hdss-1-200 bin]# chmod +x /usr/bin/cfssl*
[root@hdss-1-200 bin]# ls -lrt cf*
-rwxr-xr-x 1 root root 2277873 Feb 8 12:01 cfssl-json
-rwxr-xr-x 1 root root 6595195 Feb 8 12:01 cfssl-certinfo
-rwxr-xr-x 1 root root 10376657 Feb 8 12:01 cfssl
[root@hdss-1-200 bin]# which cfssl-certinfo
/usr/bin/cfssl-certinfo
[root@hdss-1-200 bin]# which cfssl
/usr/bin/cfssl
[root@hdss-1-200 bin]# which cfssl-json
/usr/bin/cfssl-json
5.签发证书,创建指定的目录
[root@hdss-1-200 opt]# mkdir certs
[root@hdss-1-200 opt]# cd certs/
[root@hdss-1-200 certs]#
6.创建生成CA证书签名请求(csr)的JSON配置文件
[root@hdss-1-200 certs]# vi /opt/certs/ca-csr.json
{
"CN": "OldboyEdu", # 机构名称,浏览器使用该字段验证网站是否合法,一般写的是域名,非常重要,浏览器使用该字段验证网站是否合法
"hosts": [
],
"key": {
"algo": "rsa", # 算法
"size": 2048 # 长度
},
"names": [
{
"C": "CN", # C,国家
"ST": "beijing", # ST 州,省
"L": "beijing", # L 地区 城市
"O": "od", # O 组织名称,公司名称
"OU": "ops" # OU 组织单位名称,公司部门
}
],
"ca": {
"expiry": "175200h" # expiry 过期时间,任何证书都有过期时间.20年
}
}
7.签发证书
[root@hdss-1-200 certs]# cfssl gencert -initca ca-csr.json
2021/02/08 12:13:54 [INFO] generating a new CA key and certificate from CSR
2021/02/08 12:13:54 [INFO] generate received request
2021/02/08 12:13:54 [INFO] received CSR
2021/02/08 12:13:54 [INFO] generating key: rsa-2048
2021/02/08 12:13:54 [INFO] encoded CSR
2021/02/08 12:13:54 [INFO] signed certificate with serial number 240189431803521968703357144322271086616848173037
{"cert":"-----BEGIN CERTIFICATE-----\nMIIDtDCCApygAwIBAgIUKhJ3dIfX4mYealjZtJhdi99hB+0wDQYJKoZIhvcNAQEL\nBQAwYDELMAkGA1UEBhMCQ04xEDAOBgNVBAgTB2JlaWppbmcxEDAOBgNVBAcTB2Jl\naWppbmcxCzAJBgNVBAoTAm9kMQwwCgYDVQQLEwNvcHMxEjAQBgNVBAMTCU9sZGJv\neUVkdTAeFw0yMTAyMDgxNzA5MDBaFw00MTAyMDMxNzA5MDBaMGAxCzAJBgNVBAYT\nAkNOMRAwDgYDVQQIEwdiZWlqaW5nMRAwDgYDVQQHEwdiZWlqaW5nMQswCQYDVQQK\nEwJvZDEMMAoGA1UECxMDb3BzMRIwEAYDVQQDEwlPbGRib3lFZHUwggEiMA0GCSqG\nSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC/H+E5rO6Y3Z+RjTdyTY3JerrDignTHN3v\nyOsGFM9REVD2qLFtRZ4Koj92KxuTivJm20GOgTr5UC504AhtS1L5TK9oXMR6YPtK\n36tlJ6LjJABM3nEKOr/TSQedFz6bGZ8DIJgEDIUI4QpRs71ZSsvalHfeD4W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iSnpsW2VGSjuFRR1vtrgT+o/8OuySrJDiJSTajVp\ndjPhFRMklLWwjngi2Ah9I803zBPD2IkVvyeM++8yIoCrwrt289DBiUdC4Gqae/eX\n3Sbgz4N6kF8gnGRZhCp0NUA94d84mxOO8SiapWz0IhfKjI9JNeSvoA==\n-----END RSA PRIVATE KEY-----\n"}
8.做成承载式证书
[root@hdss-1-200 certs]# ls
ca-csr.json
[root@hdss-1-200 certs]# cfssl gencert -initca ca-csr.json | cfssl-json -bare ca
2021/02/09 15:30:09 [INFO] generating a new CA key and certificate from CSR
2021/02/09 15:30:09 [INFO] generate received request
2021/02/09 15:30:09 [INFO] received CSR
2021/02/09 15:30:09 [INFO] generating key: rsa-2048
2021/02/09 15:30:10 [INFO] encoded CSR
2021/02/09 15:30:10 [INFO] signed certificate with serial number 80946315882407051316915181916096221469731026792
[root@hdss-1-200 certs]# ll
total 16
-rw-r--r-- 1 root root 993 Feb 9 15:30 ca.csr
-rw-r--r-- 1 root root 346 Feb 9 15:29 ca-csr.json
-rw------- 1 root root 1675 Feb 9 15:30 ca-key.pem
-rw-r--r-- 1 root root 1346 Feb 9 15:30 ca.pem
[root@hdss-1-200 certs]#
9.查看证书
[root@hdss-1-200 certs]# cat ca.csr
-----BEGIN CERTIFICATE REQUEST-----
MIICpTCCAY0CAQAwYDELMAkGA1UEBhMCQ04xEDAOBgNVBAgTB2JlaWppbmcxEDAO
BgNVBAcTB2JlaWppbmcxCzAJBgNVBAoTAm9kMQwwCgYDVQQLEwNvcHMxEjAQBgNV
BAMTCU9sZGJveUVkdTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMly
Swes0sjLmU7KGG3ZDiOjggopHFawF5MRbNjjpbBBIr+uscPr5TNHls6S9lYOnUF9
RCFukDxZvf7xXJDeCWovCuiowVxA/N0nt0n8ESlh3OOS/eVnoeO6k2jG7LZxFjmB
9lQHVR1Lluc6yDd+36wvCVw/xjhcrAkAAFcwbRZm7PDzuzeXbWWbxhD1hg1vC7s8
qRd24mWIPoEUV4ZxAZWtpcZRa0etstVBjrF2LR/vpFCp6AYwe7Bykx0Sz1iIz05x
xEkkIp+aKw/pwau4lKa4UzN9OcHw2y41wUQ7pWSsYTByWTJW+NEQrC5azB1YCI6M
zwyz3A8MxGLl1AG2LhsCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQA25mT5mJHR
+BDs8jq12qQjRljuVHJwDSIrLDHMOGGhIUzOBIe94Nj/tSXJ8Y7gQ+VeJIR+Yhjg
eW/8dpqOz0wqv8npXsUfmwrMWtYJu5YyuA7GLs03AwWyQIfycqAHfT1zp20YMr2j
bZkTCPiggk9Nb3k5fqyQyu7kdpvxQfS+d5Ygp5PHsU/pHzvxPhHbbIRwMGFgrrIr
6wMekRl2ruUnB2zt/RcPNcUYUnePIJLT8BakmPHyKsVouOEsqO/c470QN/KJvk3C
oxMF84qkPF1zBhS1ElMTpzXCbMQtyO0yMINvvAyPlM6NJ/4w+FO9AQG9X4f0tmrq
pPvaYwOqTV6w
-----END CERTIFICATE REQUEST-----
[root@hdss-1-200 certs]#
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/141878.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...