k8s–证书签发

k8s–证书签发1.准备签发证书环境运维主机hdss-1-200.host.com上:2.安装CFSSL证书签发工具CFSSL:R1.2cfssl下载地址https://pkg.cfssl.org/R1.2/cfssl_linux-amd64cfssl-json下载地址https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64cfssl-certinfo下载地址https://pkg.cfssl.org/R1.2/cfssl-certinfo_li…

大家好,又见面了,我是你们的朋友全栈君。

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\nEwJvZDEMMAoGA1UECxMDb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+MAUZ3Rwp\n481LfxpqbdAlBdA3HCoaXwKBgQCrzX7rOfHP2n1kQ2wZd0lyfzHUgpZL2YQVxRKD\nsHX+mqwz/cFBHWWzqkJf00LuV/k+Y8eVougguPAb5y1XpS9IVG12OCCRe13dzbZG\nNButfW02lZrFHcHpTbJ73AjVyhGaE+G/Gh8Q088OHAbLAD4BCG8PwWFwTZTLEBKQ\nk5DhkQKBgQDkXHYPgFI95olQiSnpsW2VGSjuFRR1vtrgT+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账号...

(0)


相关推荐

  • VBA编程资料[通俗易懂]

    VBA编程资料[通俗易懂]

  • 【低效编码】一个@ResponseBody注解没加让我这个菜鸟原形毕露

    【低效编码】一个@ResponseBody注解没加让我这个菜鸟原形毕露小问题暴露大知识点

  • oracle如何防止锁表,Oracle-怎么防止oracle锁表[通俗易懂]

    oracle如何防止锁表,Oracle-怎么防止oracle锁表[通俗易懂]只有插入有主键约束的列,或者有唯一约束的列时才可能会阻塞。示例:createtablet(xintprimarykey);session1:insertintotvalues(1);session2:insertintotvalues(1);这时session2就会发生阻塞。解决这种情况最好的方法就是在列上绑定一个序列,如果没有这么做,你也可以创建一个before触发器…

  • CentOS常用命令

    CentOS常用命令

  • 2014年度工作总结

    2014年度工作总结虽然还有一段时间真正的变成中国人的2015年了,回首这2年的工作,时间一晃真的很快。转眼间到鼎峰已经2年了,这是我人生中弥足珍贵的一段经历。感谢,感恩鼎峰的每一个人,因为有你们我才能快速的成长积累,这2年有硕果累累的喜悦,有工作当中的艰辛,也有遇到困难和挫折时的惆怅。在项目可开发和处理问题的过程中,难题一个接一个的出现,自信心不止一次的受到过打击,虽然自己早就知道,要做到符合公司的要求,做一名合格

  • cmd中javac和java使用及注意事项

    cmd中javac和java使用及注意事项一、简述:cmd中,执行java命令与javac命令的区别:javac:是编译命令,将java源文件编译成.class字节码文件。例如:javachello.java将生成hello.class文件。 java:是运行字节码文件;由java虚拟机对字节码进行解释和运行。例如:javahello 二、详述:下面我们来写个java文件试试。1、打开记事本…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号