自签名证书Linux的导入

自签名证书Linux的导入

系统层级:

Debain系

sudo mkdir /usr/local/share/ca-certificates/extra
sudo cp selfCA.pem /usr/local/share/ca-certificates/extra/xxx.cert.crt
sudo update-ca-certificates

Fedora系

sudo cp selfCA.pem/etc/pki/ca-trust/source/anchors
sudo update-ca-trust

在这些步骤之后,新的 CA 可用于 curl 和 get 等系统实用程序。 但大多数网络浏览器不会管这些,例如 Mozilla Firefox 或 Google Chrome。

浏览器:

通常证书储存在用户目录,名为“cert8.db”和“cert9.db”(适用于较新版本)。 您可以使用“certutil”工具修改库文件。 要安装 certutil,请执行以下 apt 命令:

sudo apt install libnss3-tools

网上找到的写的bash文件可以更改库

#!/bin/bash

### Script installs root.cert.pem to certificate trust store of applications using NSS
### (e.g. Firefox, Thunderbird, Chromium)
### Mozilla uses cert8, Chromium and Chrome use cert9

###
### Requirement: apt install libnss3-tools
###


###
### CA file to install (CUSTOMIZE!)
###

# File name path certfile
="/home/me/selfCA.pem" certname="My Root CA" ### ### For cert8 (legacy - DBM) ### for certDB in $(find ~/ -name "cert8.db") do certdir=$(dirname ${certDB}); certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:${certdir} done ### ### For cert9 (SQL) ### for certDB in $(find ~/ -name "cert9.db") do certdir=$(dirname ${certDB}); certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:${certdir} done

执行后可能会提示

Notice: Trust flag u is set automatically if the private key is present.

属于正常

之后浏览器就可以看到正常的证书了。

posted @ 2022-04-10 12:24  Dirigent  阅读(1362)  评论(0编辑  收藏  举报