默认情况下,Docker 通过非联网 UNIX 套接字运行。它还可以使用 HTTP 套接字进行可选通信。
如果需要以安全的方式通过网络访问 Docker,可以通过指定标志将 Docker 标志指向受信任的 CA 证书来启用 TLS。
在守护程序模式下,它只允许来自由该 CA 签名的证书验证的客户端的连接。在客户端模式下,它仅连接到具有该 CA 签名的证书的服务器。
# 创建CA证书目录 [root@localhost ~]# mkdir tls [root@localhost ~]# cd tls/ # 创建CA密钥 [root@localhost tls]# openssl genrsa -aes256 -out ca-key.pem 4096 Generating RSA private key, 4096 bit long modulus ..............................................................................++ .....................................................................................................................................................................++ e is 65537 (0x10001) Enter pass phrase for ca-key.pem: Verifying - Enter pass phrase for ca-key.pem: # 创建CA证书 [root@localhost tls]# openssl req -new -x509 -days 1000 -key ca-key.pem -sha256 -subj "/CN=*" -out ca.pem Enter pass phrase for ca-key.pem: [root@localhost tls]# ll 总用量 8 -rw-r--r--. 1 root root 3326 12月 3 17:20 ca-key.pem -rw-r--r--. 1 root root 1765 12月 3 19:03 ca.pem # 创建服务器私钥 [root@localhost tls]# openssl genrsa -out server-key.pem 4096 Generating RSA private key, 4096 bit long modulus ................................................................++ ..................++ e is 65537 (0x10001) [root@localhost tls]# ll 总用量 12 -rw-r--r--. 1 root root 3326 12月 3 17:20 ca-key.pem -rw-r--r--. 1 root root 1765 12月 3 19:03 ca.pem -rw-r--r--. 1 root root 3243 12月 3 19:03 server-key.pem # 对私钥进行签名 [root@localhost tls]# openssl req -subj "/CN=*" -sha256 -new -key server-key.pem -out server.csr [root@localhost tls]# ll 总用量 16 -rw-r--r--. 1 root root 3326 12月 3 17:20 ca-key.pem -rw-r--r--. 1 root root 1765 12月 3 19:03 ca.pem -rw-r--r--. 1 root root 1574 12月 3 19:04 server.csr -rw-r--r--. 1 root root 3243 12月 3 19:03 server-key.pem 使用CA证书与私钥签名,输入上面设置的密码 [root@localhost tls]# openssl x509 -req -days 1000 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem Signature ok subject=/CN=* Getting CA Private Key Enter pass phrase for ca-key.pem: #生成客户端密钥 [root@localhost tls]# openssl genrsa -out key.pem 4096 Generating RSA private key, 4096 bit long modulus ....................................................................................................................++ .................................++ e is 65537 (0x10001) #对客户端签名 [root@localhost tls]# openssl req -subj "/CN=client" -new -key key.pem -out client.csr #创建配置文件 [root@localhost tls]# echo extendedKeyUsage=clientAuth > extfile.cnf #签名证书 [root@localhost tls]# openssl x509 -req -days 1000 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile.cnf Signature ok subject=/CN=client Getting CA Private Key Enter pass phrase for ca-key.pem: [root@localhost tls]# ll 总用量 40 -rw-r--r--. 1 root root 3326 12月 3 17:20 ca-key.pem -rw-r--r--. 1 root root 1765 12月 3 19:03 ca.pem -rw-r--r--. 1 root root 17 12月 3 19:35 ca.srl -rw-r--r--. 1 root root 1696 12月 3 19:35 cert.pem -rw-r--r--. 1 root root 1582 12月 3 19:29 client.csr -rw-r--r--. 1 root root 28 12月 3 19:32 extfile.cnf -rw-r--r--. 1 root root 3243 12月 3 19:08 key.pem -rw-r--r--. 1 root root 1647 12月 3 19:08 server-cert.pem -rw-r--r--. 1 root root 1574 12月 3 19:04 server.csr -rw-r--r--. 1 root root 3243 12月 3 19:03 server-key.pem # 删除多余文件 [root@localhost tls]#
在客户端测试
[root@client ~]# docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H tcp://master:2376 version Client: Docker Engine - Community Version: 19.03.13 API version: 1.40 Go version: go1.13.15 Git commit: 4484c46d9d Built: Wed Sep 16 17:03:45 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.13 API version: 1.40 (minimum version 1.12) Go version: go1.13.15 Git commit: 4484c46d9d Built: Wed Sep 16 17:02:21 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.3.9 GitCommit: ea765aba0d05254012b0b9e595e995c09186427f runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
岱庙资源网 Copyright www.zgmyg.com
暂无“使用TLS加密通讯远程连接Docker的示例详解”评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年06月18日
2024年06月18日
- 原神:4.7新深渊攻略|配队与思路分享,难度有所上涨
- 群星《70/80/90年代经典老歌精选1100首》[MP3][10.5G]
- 孙露《观心》1:1母盘直刻限量版[低速原抓WAV+CUE][361M]
- 庄心妍《念》[WAV+CUE][388M]
- 赵坤宇《东方弦韵STS+TD》[WAV+CUE]
- YayaBey《TenFold》(2024)[WAV]
- [In-Akustik19007]FreshBlues-TheInakBlues-ConnectionVol.7(2013)[WAV+CUE]
- 林宥嘉《王 Love, Lord》[320K/MP3][115.78MB]
- 林宥嘉《王 Love, Lord》[FLAC/分轨][268.79MB]
- 群星《烈焰 影视原声带》[320K/MP3][226.72MB]
- 张国荣1997-狂恋张国荣国语经典[巨星发烧HI-END20bit系列][宝丽金]WAV+CUE
- [发烧音乐]顶级音质《尊宝试音碟》绝版限量非卖品[WAV+CUE]
- 群星《紫水晶试音王2号》三维环绕特效天碟[WAV+CUE]
- SNH48袁一琦《24》[320K/MP3][32.74MB]
- SNH48袁一琦《24》[FLAC/分轨][100.42MB]