

Docker 开启远程SSL证书认证
source link: https://blog.yinaun.com/posts/27708.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用openssl制作证书密钥
在服务器中新建一个目录,并切换到该目录下
mkdir /etc/docker && cd /etc/docker
创建根证书RSA私钥
openssl genrsa -aes256 -out ca-key.pem 4096
此处需要两次输入密码,请务必记住该密码,在后面步骤会用到
创建CA证书
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
该步骤以上一步生成的密钥创建证书,也就是自签证书,也可从第三方CA机构签发
创建服务端私钥
openssl genrsa -out server-key.pem 4096
创建服务端签名请求证书文件
openssl req -subj "/CN=118.31.40.556" -sha256 -new -key server-key.pem -out server.csr
其中的IP地址为自己服务器IP地址
创建extfile.cnf的配置文件
echo subjectAltName = IP:118.31.40.556,IP:0.0.0.0 >> extfile.cnf
echo extendedKeyUsage = serverAuth >> extfile.cnf
其中IP地址改为自己服务器IP地址
创建签名生效的服务端证书文件
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \-CAcreateserial -out server-cert.pem -extfile extfile.cnf
创建客户端私钥
openssl genrsa -out key.pem 4096
创建客户端签名请求证书文件
openssl req -subj '/CN=client' -new -key key.pem -out client.csr
extfile.cnf文件中增加配置
echo extendedKeyUsage = clientAuth >> extfile.cnf
创建签名生效的客户端证书文件
openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem \-CAcreateserial -out cert.pem -extfile extfile.cnf
删除无用文件
rm -v client.csr server.csr
为证书文件授权
chmod -v 0400 ca-key.pem key.pem server-key.pem
chmod -v 0444 ca.pem server-cert.pem cert.pem
配置Docker支持TLS连接
编辑docker.service配置文件
vim /lib/systemd/system/docker.service
找到**ExecStart=**开头的一行代码,将其替换为如下内容
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375 --tlsverify --tlscacert=/etc/docker/ca.pem --tlscert=/etc/docker/server-cert.pem --tlskey=/etc/docker/server-key.pem
此处设置docker远程端口为2375,可根据需要修改
刷新配置,重启Docker
systemctl daemon-reload && systemctl restart docker
Recommend
-
51
程序员 - @luzhongqiu - ssl 证书好贵啊, 阿里,腾讯等,都在 2 千到 2w 不等, 各位老铁有办法便宜的 ssl 证书能过小程序审核的?
-
50
-
50
作者 | 黄超 杏仁运维工程师,关注容器技术和自动化运维。 前言 当今随着人们对网络安全意识的增强,越来越多的网...
-
16
首页 > 其他, 移动端 > SSL中间证书的坑 SSL中...
-
15
SSL 中间证书配置,兼谈昨支付宝证书错误SSL 中间证书配置,兼谈昨支付宝证书错误 本文来自
-
7
godaddy ssl证书续费, nginx配置 欢迎转载,请支持原创,保留原文链接:blog.ilibrary.me...
-
9
阿里云申请免费SSL证书 2017-09-12 00:54:08 +08 字数:1306 标签: Aliyun HTTPS...
-
11
将自签发的SSL证书导入为Firefox中的受信任根证书 作者: wencst 分类: Uncategorized,window...
-
5
将自签发的SSL证书导入为IE中的受信任根证书 作者: wencst 分类: Uncategorized,windows...
-
11
网站的SSL有什么作用呢? 如果没有SSL证书,连接可能不安全,与网站交互的信息可能被其他人获取,对于无论是自己或者自己的用户都是一种损失,而且还会造成网站劫持等等问题,使用SSL证书可以大大地减轻网站的安全性的问题。 使用SSL有什么缺点吗? 有的...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK