1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| # 服务器证书请求配置文件
$ cat 172.16.100.92-csr.json { "CN": "172.16.100.92", "hosts": [ "172.16.100.92", "kube-master" ], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "BeiJing", "ST": "BeiJing", "O": "soyuan", "OU": "spzl" } ] }
# 生成证书策略文件 $ cat ca-config.json { "signing": { "default": { "expiry": "87600h" }, "profiles": { "server": { "expiry": "87600h", "usages": [ "signing", "key encipherment", "server auth", "client auth" ] }, "intermediate": { "expiry": "87600h", "usages": [ "signing", "key encipherment", "cert sign", "crl sign", "server auth", "client auth" ] } } } }
# 生成证书 $ cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=92 172.16.100.92-csr.json | cfssljson -bare 172.16.100.92 # 单独生成csr文件 $ cfssl genkey csr.json | cfssljson -bare 172.16.100.92 # 证书和私钥合并成pfx $ openssl pkcs12 -export -out certificate.pfx -inkey private_key.pem -in certificate.pem -certfile intermediate_cert.pem # pfx 提取证书和私钥 $ openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private_key.pem $ openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem $ openssl verify -CAfile ca.pem intermediate.pem
|