diff options
author | James Crayne <jim.crayne@gmail.com> | 2014-05-06 20:43:29 -0400 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2014-05-06 20:43:29 -0400 |
commit | f751f74f213f968e7d56b73e9058a62f9fa87d3f (patch) | |
tree | 013bdf9a85b619bc76a93ccb665d68dd2dff69f8 /examples/browser-export.sh | |
parent | cd074ee590e82bfc9449072c78c97db2d3c1e064 (diff) | |
parent | c3e54b0c9a274ed411294848d98c72fe3c204888 (diff) |
Merge branch 'master' of jotunheim:samizdat/kiki
Diffstat (limited to 'examples/browser-export.sh')
-rwxr-xr-x | examples/browser-export.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/browser-export.sh b/examples/browser-export.sh new file mode 100755 index 0000000..efb51de --- /dev/null +++ b/examples/browser-export.sh | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | extract_certificate_and_private_key() | ||
4 | { | ||
5 | passphrase_file=$(mktemp) || exit | ||
6 | echo asdf > $passphrase_file | ||
7 | local nssdb="$1" name="$2" | ||
8 | pk12util -d sql:"$nssdb" -n "$name" -w "$passphrase_file" -o /dev/stdout | | ||
9 | openssl pkcs12 -passin file:"$passphrase_file" -nodes | ||
10 | rm "$passphrase_file" | ||
11 | } | ||
12 | |||
13 | extract_public_key() | ||
14 | { | ||
15 | local nssdb="$1" name="$2" | ||
16 | certutil -d sql:"$nssdb" -L -n "$name" -a | openssl x509 -pubkey -noout | ||
17 | } | ||
18 | |||
19 | for nssdb in "$HOME/.pki/nssdb" "$HOME"/.mozilla/firefox/*; do | ||
20 | [ -d "$nssdb" ] || continue | ||
21 | [ -e "$nssdb"/cert8.db -o -e "$nssdb"/cert9.db ] || continue | ||
22 | echo "nssdb=$nssdb" >&2 | ||
23 | certutil -d sql:"$nssdb" -L | sed -ne 's/ *.,.,.$//p' | | ||
24 | while read name; do | ||
25 | |||
26 | # certutil -d sql:"$nssdb" -K -n "$name" | ||
27 | # extract_public_key "$nssdb" "$name" | ||
28 | extract_certificate_and_private_key "$nssdb" "$name" | ||
29 | |||
30 | done | ||
31 | done | ||