SSL certificate problem certificate has expired

我在Amazon EC2执行yum时报错如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@Linux ~]# yum repolist
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00:00
https://repo.zabbix.com/zabbix/5.4/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "SSL certificate problem: certificate has expired"
Trying other mirror.
https://repo.zabbix.com/zabbix/5.4/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "SSL certificate problem: certificate has expired"
Trying other mirror.
https://repo.zabbix.com/non-supported/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "SSL certificate problem: certificate has expired"
Trying other mirror.
repo id repo name status
amzn2-core/2/x86_64 Amazon Linux 2 core repository 26,893
amzn2extra-docker/2/x86_64 Amazon Extras repo for docker 55
amzn2extra-epel/2/x86_64 Amazon Extras repo for epel 1
amzn2extra-lamp-mariadb10.2-php7.2/2/x86_64 Amazon Extras repo for lamp-mariadb10.2-php7.2 609

........

其中报错:[Errno 14] curl#60 - “SSL certificate problem: certificate has expired”,很明显时提示证书过期,

解决方法

1.下载最新的证书:https://curl.se/ca/cacert.pem

2.Amazon EC2解决过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 获取证书位置
[root@Linux ~]# curl-config --ca
/etc/pki/tls/certs/ca-bundle.crt

# 查看证书文件
[root@Linux ~]# ls -la /etc/pki/tls/certs/ca-bundle.crt
lrwxrwxrwx 1 root root 49 Aug 6 2020 /etc/pki/tls/certs/ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem

# 备份原文件
mv /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem.bak

# 下载最新证书(-L是为了跟踪重定向,-v是为了查看具体信息)
curl -o /etc/pki/ca-trust/extracted/pem/cacert.pem "http://curl.haxx.se/ca/cacert.pem" -L -v

# 修改名称
mv /etc/pki/ca-trust/extracted/pem/cacert.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem

3.再次执行yum测试

1
2
3
4
5
6
7
8
9
10
11
12
[root@Linux ~]# yum repolist
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd

19 packages excluded due to repository priority protections
repo id repo name status
amzn2-core/2/x86_64 Amazon Linux 2 core repository 26,893
amzn2extra-docker/2/x86_64 Amazon Extras repo for docker 55
amzn2extra-epel/2/x86_64 Amazon Extras repo for epel 1
amzn2extra-lamp-mariadb10.2-php7.2/2/x86_64 Amazon Extras repo for lamp-mariadb10.2-php7.2 609
amzn2extra-php7.2/2/x86_64 Amazon Extras repo for php7.2 737
centos-sclo-rh/x86_64 CentOS-7 - SCLo rh 7,775+19
.......

可以看到已经可以正常使用。

-------------本文结束感谢您的阅读-------------