Ubuntu 添加可信任根证书

发布于 2024-06-04 10:21:56 字数 1381 浏览 24 评论 0

添加

Ubuntu 下添加根证书非常简单, 只要将证书(扩展名为 crt)复制到 /usr/local/share/ca-certificates 文件夹然后运行 update-ca-certificates 即可

[yaxin@ubox ~]$sudo cp xinmu.crt /usr/local/share/ca-certificates
[yaxin@ubox ~]$sudo update-ca-certificates
Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.

删除

直接将 /usr/local/share/ca-certificates 对应的证书删除,然后执行 update-ca-certificates

[yaxin@ubox ~]$sudo rm -f /usr/local/share/ca-certificates/xinmu.crt
[yaxin@ubox ~]$sudo update-ca-certificates
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.

注意: 这时候并不会提示 1 removed, 但证书是已经被删除了的

原理

其实 update-ca-certificates 是一个 shell 脚本,使用 which 找出 update-ca-certificates 的绝对路径,然后打开就可以查看其源码

[yaxin@ubox ~]$which update-ca-certificates
/usr/sbin/update-ca-certificates
[yaxin@ubox ~]$file /usr/sbin/update-ca-certificates
/usr/sbin/update-ca-certificates: POSIX shell script, ASCII text executable

通过阅读源码可以看出, update-ca-certificates 命令的本质其实是将 PEM 格式的根证书内容附加到 /etc/ssl/certs/ca-certificates.crt,而 /etc/ssl/certs/ca-certificates.crt 中本身就包含了系统自带的各种可信根证书。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

酷炫老祖宗

暂无简介

文章
评论
28 人气
更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文