自簽名證書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.
屬於正常
之后瀏覽器就可以看到正常的證書了。