解决ssl certificates updated-生成环境中的实例

2024-08-27 07:36

本文主要是介绍解决ssl certificates updated-生成环境中的实例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

应原来小伙伴的要求,生产环境出错了,是harbor的ssl cert过期了,也因为使用的是免费的ssl证书,现在无法正常使用harbor,所以贴来了2023年1月曾经搭建的文档,希望能解决问题。^v^.

-------------------------------------------------------------------------------------------------------------------------------

以下是历史正文记录:

最近发现其中一个域名的证书到期了,无赖,现在行情不好,所以没准备续费购买商用版的证书,自己搭建把。好几个ssl证书都颁发使用(如下域名服务),域名为阿里购买的,所以原来的证书也是阿里的。

写个docs,就是update harbor的ssh crt把。

0、登录:https://harbortest.ihlt.com即出现以下界面,配置了ssl证书想通过IP也访问不了!

登录aliyun申请免费的证书把,需要购买证书服务,用了公司的企业账号,一次性可以免费申请20个,但是并非是根证书哦。截图记录把。

这里我看了harbor原来的证书格式为crt,密钥为key

所以我下载了对应的nginx的

应该harbor的证书也是通过nginx来写的

harbor@uat-harbor01:~$ sudo -i

[sudo] password for harbor:

root@uat-harbor01:~# cd /root/harbor/

root@uat-harbor01:~/harbor# ls

common  common.sh  docker-compose.yml  harbor.v2.6.0.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare

root@uat-harbor01:~/harbor# ls

common  common.sh  docker-compose.yml  harbor.v2.6.0.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare

root@uat-harbor01:~/harbor# cd /data/cert/

root@uat-harbor01:/data/cert# ls

harbortest.ihlt.com.crt  harbortest.ihlt.com.key

root@uat-harbor01:/data/cert#

root@uat-harbor01:~/harbor# cat harbor.yml

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.

# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.

hostname: harbortest.ihlt.com

# http related config

http:

  # port for http, default is 80. If https enabled, this port will redirect to https port

  port: 80

# https related config

https:

  # https port for harbor, default is 443

  port: 443

  # The path of cert and key files for nginx

  certificate: /data/cert/harbortest.ihlt.com.crt

  private_key: /data/cert/harbortest.ihlt.com.key

依次操作如下图,

2、更新证书:

把下载的证书拷贝到对应的目录

通过finnalshell的sftp来直接拉传

root@uat-harbor01:/data/cert# ls

harbortest.ihlt.com.crt  harbortest.ihlt.com.key

root@uat-harbor01:/data/cert# mv harbortest.ihlt.com.crt harbortest.ihlt.com.crt0

root@uat-harbor01:/data/cert# mv harbortest.ihlt.com.key harbortest.ihlt.com.key0

root@uat-harbor01:/data/cert# mv /tmp/harbortest.ihlt.com.* ./

root@uat-harbor01:/data/cert# ls

harbortest.ihlt.com.crt0  harbortest.ihlt.com.key  harbortest.ihlt.com.key0  harbortest.ihlt.com.pem

root@uat-harbor01:/data/cert# ls -al

total 24

drwxr-xr-x 2 root   root   4096 Sep  1 09:19 .

drwxr-xr-x 4 root   root   4096 Oct 11  2022 ..

-rw-r--r-- 1 harbor harbor 3805 Oct 11  2022 harbortest.ihlt.com.crt0

-rw-rw-r-- 1 harbor harbor 1675 Sep  1 09:13 harbortest.ihlt.com.key

-rw-r--r-- 1 harbor harbor 1675 Oct 11  2022 harbortest.ihlt.com.key0

-rw-rw-r-- 1 harbor harbor 3813 Sep  1 09:13 harbortest.ihlt.com.pem

root@uat-harbor01:/data/cert#

3、重启harbor

停止docker-compose down

重新执行./prepare

启动docker-compose up -d

root@uat-harbor01:~/harbor# ./prepare

prepare base dir is set to /root/harbor

Clearing the configuration file: /config/portal/nginx.conf

Clearing the configuration file: /config/log/rsyslog_docker.conf

Clearing the configuration file: /config/log/logrotate.conf

Generated configuration file: /config/portal/nginx.conf

Generated configuration file: /config/log/logrotate.conf

Generated configuration file: /config/log/rsyslog_docker.conf

Traceback (most recent call last):

  File "/usr/src/app/main.py", line 15, in <module>

    cli()

  File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in __call__

    return self.main(*args, **kwargs)

  File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in main

    rv = self.invoke(ctx)

  File "/usr/lib/python3.10/site-packages/click/core.py", line 1668, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke

    return __callback(*args, **kwargs)

  File "/usr/src/app/commands/prepare.py", line 47, in prepare

    prepare_nginx(config_dict)

  File "/usr/src/app/utils/nginx.py", line 23, in prepare_nginx

    render_nginx_template(config_dict)

  File "/usr/src/app/utils/nginx.py", line 56, in render_nginx_template

    prepare_nginx_certs(config_dict['cert_key_path'], config_dict['cert_path'])

  File "/usr/src/app/utils/nginx.py", line 43, in prepare_nginx_certs

    shutil.copy2(host_ngx_cert_path, real_crt_path)

  File "/usr/lib/python3.10/shutil.py", line 434, in copy2

    copyfile(src, dst, follow_symlinks=follow_symlinks)

  File "/usr/lib/python3.10/shutil.py", line 254, in copyfile

    with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: '/hostfs/data/cert/harbortest.ihlt.com.crt'

//马虎,提示没有这个文件,所以去看了下,忘记了上面的harbor.yml的crt而不是拷贝进来的pem,所以进入目录可以直接修改即可。

root@uat-harbor01:~/harbor# cd /data/cert/

root@uat-harbor01:/data/cert# ls

harbortest.ihlt.com.crt0  harbortest.ihlt.com.key  harbortest.ihlt.com.key0  harbortest.ihlt.com.pem

root@uat-harbor01:/data/cert# mv harbortest.ihlt.com.pem harbortest.ihlt.com.crt

root@uat-harbor01:~/harbor# ./prepare

prepare base dir is set to /root/harbor

Clearing the configuration file: /config/portal/nginx.conf

Clearing the configuration file: /config/log/rsyslog_docker.conf

Clearing the configuration file: /config/log/logrotate.conf

Generated configuration file: /config/portal/nginx.conf

Generated configuration file: /config/log/logrotate.conf

Generated configuration file: /config/log/rsyslog_docker.conf

Generated configuration file: /config/nginx/nginx.conf

Generated configuration file: /config/core/env

Generated configuration file: /config/core/app.conf

Generated configuration file: /config/registry/config.yml

Generated configuration file: /config/registryctl/env

Generated configuration file: /config/registryctl/config.yml

Generated configuration file: /config/db/env

Generated configuration file: /config/jobservice/env

Generated configuration file: /config/jobservice/config.yml

loaded secret from file: /data/secret/keys/secretkey

Generated configuration file: /compose_location/docker-compose.yml

Clean up the input dir

root@uat-harbor01:~/harbor# docker-compose up -d

[+] Running 10/10

  Network harbor_harbor        Created                                                                              0.2s

  Container harbor-log         Started                                                                              0.8s

  Container registryctl        Started                                                                              1.4s

  Container harbor-portal      Started                                                                              1.7s

  Container redis              Started                                                                              1.8s

  Container registry           Started                                                                              1.7s

  Container harbor-db          Started                                                                              1.3s

  Container harbor-core        Started                                                                              1.9s

  Container nginx              Started                                                                              2.3s

  Container harbor-jobservice  Started                                                                              2.2s

root@uat-harbor01:~/harbor#

再次访问:恢复正常了!

nginx更新证书-2023/10/19

公司的holitech.net的证书过期了,阿里云上购买了根证书。首先上传服务,然后替换对应的路径,可以查看nginx.conf的配置:路径,然后必须重启nginx服务。后端测试OK。。。。!

[root@k8s-ng2 paas]# scp holitech.net.* root@10.6.200.223:/root/

ssh: connect to host 10.6.200.223 port 22: Connection refused

lost connection

[root@k8s-ng2 paas]# scp holitech.net.* root@10.0.200.223:/data/cert

root@10.0.200.223's password:

holitech.net.key                                                                                                      100% 1679    18.3KB/s   00:00   

holitech.net.pem                                                                                                      100% 3822   987.3KB/s   00:00   

[root@k8s-ng1 data]# cd cert/

[root@k8s-ng1 cert]# ls

8631154__holitech.net.key  holitech.net.key

8631154__holitech.net.pem  holitech.net.pem

[root@k8s-ng1 cert]# mv  holitech.net.key 8631154__holitech.net.key

mv:是否覆盖"8631154__holitech.net.key" y

[root@k8s-ng1 cert]# mv holitech.net.pem 8631154__holitech.net.pem

mv:是否覆盖"8631154__holitech.net.pem" y

[root@k8s-ng1 cert]# whereis ngix

ngix:[root@k8s-ng1 cert]# whereis nginx

nginx: /usr/local/nginx

[root@k8s-ng1 cert]# cd /usr/local/nginx/

[root@k8s-ng1 nginx]# ls

client_body_temp  fastcgi_temp  logs        sbin       uwsgi_temp

conf              html          proxy_temp  scgi_temp

[root@k8s-ng1 nginx]# cd sbin/

[root@k8s-ng1 sbin]# ls

nginx

[root@k8s-ng1 sbin]# ./nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@k8s-ng1 sbin]# systemctl restart nginx

[root@k8s-ng2 paas]# systemctl restart nginx

--------------------------------------------------------------------------------------------------------

crt证书信息:

Harbor.ihlt.com_chain的证书

详细信息如下:

版本 :V3

序列号:0de0ffb5ee62cb61109f608c9ced5ed3

签名算法: sha256RSA

签名哈希算法: sha256

颁发者:

CN = DigiCert Global Root G2

OU = www.digicert.com

O = DigiCert Inc

C = US

有效期从: Monday, ‎November ‎27, ‎2017 8:46:40 PM

到: ‎Saturday, ‎November ‎27, ‎2027 8:46:40 PM

使用者:

CN = Encryption Everywhere DV TLS CA - G2

OU = www.digicert.com

O = DigiCert Inc

C = US

公钥:

30 82 01 0a 02 82 01 01 00 ef 14 7f 8e a2 fe 7a fb a6 48 13 0e a9 c4 79 22 1f 08 5a af 3e 75 2a dd a1 75 b4 c2 79 86 1f 4c 9c ee 8b 9a de 54 74 77 c1 1b 00 bd 4a 2f 97 8c ad 76 72 36 60 c4 e6 ec 2f a4 60 d6 78 ef 36 10 0c 27 82 6e 9c dd 09 18 64 49 19 27 af 6c 9b 00 de c7 3a f2 76 cf 43 3b 8a a7 92 5c f2 fa 6b ca 9d a6 b6 cd fc a5 20 97 a2 b3 d1 fa c7 21 42 2b 0a 03 b3 92 43 53 23 70 53 74 77 bb 5b ad c7 96 14 d6 f3 80 bd 9c b0 95 50 7a 88 0e 04 64 9e fc a6 44 21 9c 3a 81 72 ca 78 57 bb 9a ea 67 35 82 51 3a 2d a2 0b 5d 7e 1e e1 7b f6 20 2d b4 c7 37 d8 2b fa 50 ec 62 c5 8f f7 65 5f 8b ce 92 e7 92 51 6a f7 c5 ce 46 0c 24 20 92 f5 1e eb cf 85 af 32 bd bf 96 e8 98 ac 95 92 4b f8 72 c5 b6 27 68 c6 62 3b 42 6d d9 c8 85 7a e9 6e 77 dc 3b 06 16 29 85 26 4c f7 cb 41 9e 1d 6b 92 54 c6 c8 95 fb 02 03 01 00 01

公钥参数: 05 00

使用者密钥标识符:78df91905feedeacf6c575ebd54c5553ef244ab6

授权密钥标识符: KeyID=4e2254201895e6e36ee60ffafab912ed06178f39

增强型密钥用法:

服务器身份验证 (1.3.6.1.5.5.7.3.1)

客户端身份验证 (1.3.6.1.5.5.7.3.2)

授权信息访问:

[1]Authority Info Access

     Access Method=联机证书状态协议 (1.3.6.1.5.5.7.48.1)

     Alternative Name:

          URL=http://ocsp.digicert.com

CRL分发点:

[1]CRL Distribution Point

     Distribution Point Name:

          Full Name:

               URL=http://crl3.digicert.com/DigiCertGlobalRootG2.crl

证书策略:

[1]Certificate Policy:

     Policy Identifier=2.16.840.1.114412.1.2

     [1,1]Policy Qualifier Info:

          Policy Qualifier Id=CPS

          Qualifier:

               Legal Repository | DigiCert.com

[2]Certificate Policy:

     Policy Identifier=2.23.140.1.2.1

密钥用法: Digital Signature, Certificate Signing, Off-line CRL Signing, CRL Signing (86)

基本约束:

Subject Type=CA

Path Length Constraint=0

指纹: ed6302684a3259aa04f10fe9a97a8fd30b965d26

常规信息:

颁发给: Encryption Everywhere DV TLS CA - G2

颁发者: DigiCert Global Root G2

Harbor.ihlt.com_public的证书

常规信息:

颁发给: harbor.ihlt.com

颁发者: Encryption Everywhere DV TLS CA - G2

这篇关于解决ssl certificates updated-生成环境中的实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1111041

相关文章

Vue3 如何通过json配置生成查询表单

《Vue3如何通过json配置生成查询表单》本文给大家介绍Vue3如何通过json配置生成查询表单,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录功能实现背景项目代码案例功能实现背景通过vue3实现后台管理项目一定含有表格功能,通常离不开表单

Java中字符编码问题的解决方法详解

《Java中字符编码问题的解决方法详解》在日常Java开发中,字符编码问题是一个非常常见却又特别容易踩坑的地方,这篇文章就带你一步一步看清楚字符编码的来龙去脉,并结合可运行的代码,看看如何在Java项... 目录前言背景:为什么会出现编码问题常见场景分析控制台输出乱码文件读写乱码数据库存取乱码解决方案统一使

C++右移运算符的一个小坑及解决

《C++右移运算符的一个小坑及解决》文章指出右移运算符处理负数时左侧补1导致死循环,与除法行为不同,强调需注意补码机制以正确统计二进制1的个数... 目录我遇到了这么一个www.chinasem.cn函数由此可以看到也很好理解总结我遇到了这么一个函数template<typename T>unsigned

通过Docker容器部署Python环境的全流程

《通过Docker容器部署Python环境的全流程》在现代化开发流程中,Docker因其轻量化、环境隔离和跨平台一致性的特性,已成为部署Python应用的标准工具,本文将详细演示如何通过Docker容... 目录引言一、docker与python的协同优势二、核心步骤详解三、进阶配置技巧四、生产环境最佳实践

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

Java使用Javassist动态生成HelloWorld类

《Java使用Javassist动态生成HelloWorld类》Javassist是一个非常强大的字节码操作和定义库,它允许开发者在运行时创建新的类或者修改现有的类,本文将简单介绍如何使用Javass... 目录1. Javassist简介2. 环境准备3. 动态生成HelloWorld类3.1 创建CtC

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

504 Gateway Timeout网关超时的根源及完美解决方法

《504GatewayTimeout网关超时的根源及完美解决方法》在日常开发和运维过程中,504GatewayTimeout错误是常见的网络问题之一,尤其是在使用反向代理(如Nginx)或... 目录引言为什么会出现 504 错误?1. 探索 504 Gateway Timeout 错误的根源 1.1 后端

解决升级JDK报错:module java.base does not“opens java.lang.reflect“to unnamed module问题

《解决升级JDK报错:modulejava.basedoesnot“opensjava.lang.reflect“tounnamedmodule问题》SpringBoot启动错误源于Jav... 目录问题描述原因分析解决方案总结问题描述启动sprintboot时报以下错误原因分析编程异js常是由Ja