| 1 |
#!/bin/bash -e |
| 2 |
# |
| 3 |
# Inserts all local *.crt to user's browsers (webkit (chromium, ..) & mozilla (firefox, ..)) cert db's as trusted |
| 4 |
# |
| 5 |
# Comes handy when testing SSL with self-signed and such. May also be |
| 6 |
# useful on a normal production system if you keep (self signed, your |
| 7 |
# privately CA) certs in /usr/local/share/ca-certificates/. |
| 8 |
# |
| 9 |
# Note that these browsers do not use (Debian's) system default cert database (ca-certificates), else this tool would not be needed. |
| 10 |
# |
| 11 |
# Depends: libnss3-tools |
| 12 |
# See Also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=926388 |
| 13 |
|
| 14 |
main() |
| 15 |
{ |
| 16 |
local pkiDir="${HOME}/.pki" trust="C,," |
| 17 |
[ "${MBD_CODENAME}" != "buster" ] || trust="P,," |
| 18 |
local c |
| 19 |
for c in /usr/local/share/ca-certificates/*.crt; do |
| 20 |
if [ -e "${pkiDir}/nssdb" ]; then |
| 21 |
printf "I: [webkit] Adding %s to %s...\n" "${c}" "${pkiDir}" |
| 22 |
certutil -d sql:${pkiDir}/nssdb -A -t "${trust}" -n"$(basename ${c} .pem)" -i "${c}" || read -p "[chromium] FYI: ${pkiDir} seems broke [RET]" DUMMY |
| 23 |
fi |
| 24 |
|
| 25 |
local certDB |
| 26 |
for certDB in $(find ${HOME}/.mozilla/ -name "cert*.db"); do |
| 27 |
printf "I: [mozilla] Adding %s to %s...\n" "${c}" "${certDB}" |
| 28 |
certutil -d $(dirname "${certDB}") -A -t "${trust}" -n"$(basename ${c} .pem)" -i "${c}"|| read -p "[firefox] FYI: ${certDB} seems broke [RET]" DUMMY |
| 29 |
done |
| 30 |
done |
| 31 |
} |
| 32 |
|
| 33 |
main |