centos信任自建CA证书

本文介绍了解决自建CA证书在Linux环境下使用curl访问时出现的信任问题。通过将自建CA证书添加到系统的信任证书库,或者使用特定的命令选项,可以使系统正确验证自建的HTTPS证书。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们经常会用配置网站可以用https访问,但是购买证书不现实,所以我们会选择自建CA证书,但是自建的CA证书,在linux中用curl访问时总会报错,报错信息如下:

curl: (60) Peer certificate cannot be authenticated with known CA certificates
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.


让centos系统信任自建CA证书的方式如下:

将自建的CA证书追加到文件/etc/pki/tls/certs/ca-bundle.crt中:

我先将自建的CA证书上传到服务器中,名称为a.crt,然后执行命令:

              # cat a.crt >>/etc/pki/tls/certs/ca-bundle.crt

证书已经添加信任成功

还有一种方式是用工具去添加,命令是   update-ca-trust,感兴趣的可以自行百度一下

 

您是想了解如何在CentOS 7上安装CA证书吗? 安装CA证书的步骤如下: 1. 将CA证书文件上传到CentOS 7服务器。您可以使用scp命令(Secure Copy)将证书文件从本地计算机复制到服务器上。例如,假设您的证书文件名为ca.crt,服务器IP地址为192.168.1.100,您可以运行以下命令将证书文件复制到服务器上: ``` scp ca.crt username@192.168.1.100:/path/to/destination ``` 请将`username`替换为您在服务器上的用户名,`192.168.1.100`替换为您服务器的实际IP地址,`/path/to/destination`替换为您希望将证书文件复制到的目标路径。 2. 将CA证书文件移动到适当的位置。一般来说,您可以将CA证书文件移动到`/etc/pki/ca-trust/source/anchors/`目录中。使用以下命令将证书文件移动到该目录: ``` sudo mv /path/to/destination/ca.crt /etc/pki/ca-trust/source/anchors/ ``` 请将`/path/to/destination/ca.crt`替换为您实际上传证书文件的路径。 3. 更新CA证书信任。运行以下命令更新CA证书信任: ``` sudo update-ca-trust ``` 这将重新生成CA证书信任存储。 4. 验证CA证书安装。您可以运行以下命令验证CA证书是否成功安装: ``` openssl verify -CAfile /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /path/to/destination/ca.crt ``` 请将`/path/to/destination/ca.crt`替换为您实际上传证书文件的路径。 以上是在CentOS 7上安装CA证书的一般步骤。请注意,具体步骤可能会因您的环境而有所不同。在实际操作时,请根据您的需求和服务器配置进行相应调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值