<QNAP 453D QTS-5.x> 日志记录:Docker 运行的 Flask 应用 SSL 证书 过期, 更新证书

延续上一遍:

<QNAP 453D QTS-5.x> 日志记录:在 Docker 中运行的 Flask 应用安装 自签名 SSL 证书 解决 Chrome 等浏览器证书安全

当初想着为了安全,用的是默认:1月。 这不证书就过期,只能更新证书。

更新证书:

两种方式:

  1. 生成 新的证书、 新的私钥 (Flask 应用替换2文件,windows 上导入1个证书)
  2. 使用旧的私钥,只生成新证书 (Flask 应用替换1文件,windows 上导入1个证书)

这里介绍 第二种方法

环境:

还是使用上次的 Container: 6eb329c9609b 主要是利用上次的/etc/ssl/openssl.conf 省事儿

执行命令:

1. 只生成新的证书:

CMD:openssl req -x509 -key key.pem -out new_cert.pem -days 365 -config ./ssl/openssl.cnf

注释:添加了 -days 365, 让证书的有效期为1年

复制代码
root@6eb329c9609b:/app# openssl req -x509 -key key.pem -out new_cert.pem -days 365 -config ./ssl/openssl.cnf
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Beijing
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Freedome China !!!
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:davens
Email Address []:dave@gmail.com
root@6eb329c9609b:/app# ls
app.py  cert.pem  certbot  data  key.pem  new_cert.pem  requirements.txt  ssl  static  templates
root@6eb329c9609b:/app#

上面的内容当时没有写入 config 文件,只能重填一次。 注意事项同上一遍。

2. 复制 new_cert.pem 改名并代换 已有的 cert.pem
复制代码
[/share/Multimedia/2024-MyProgramFiles] # docker cp cert.pem 6eb329c9609b:/app/

docker ID : 6eb329c9609b是我 portal

3. 在 Windows 11 中添加证书, 方式也同上一篇
4. 证书生效
重启 docker container.
复制代码
[/share/Multimedia/2024-MyProgramFiles] # docker stop 6eb329c9609b
6eb329c9609b
[/share/Multimedia/2024-MyProgramFiles] # docker start 6eb329c9609b
6eb329c9609b
[/share/Multimedia/2024-MyProgramFiles] #
重启浏览器:

证书会生效

以后写代码,要考虑从某个位置下载 证书文件。 现在要往12个 containers 里面去复制........

相关推荐
辉的技术笔记1 小时前
Dify 自部署为什么跑不动?6 层瓶颈诊断法教你定位
docker
程序员老赵1 天前
Docker 部署 Redmine:老牌开源项目管理部署实测记录
docker·开源·团队管理
程序员老赵1 天前
服务器文件不想 SFTP 上传?Docker 跑个 File Browser,浏览器就能管理
服务器·docker·开源
lichenyang4533 天前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4533 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4533 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4533 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
Patrick_Wilson8 天前
从「改个端口」到 502:Next.js on k8s 的容器端口、Service 映射与 env 覆盖
docker·kubernetes·next.js
Suroy8 天前
DockerView-Go:用 Go 写一个终端 Docker 监控工具,顺便做了个 Web 仪表盘
docker
云恒要逆袭8 天前
运行你的第一个Docker容器
后端·docker·容器