blob: 7d691ff6b9939bcf2a2aee057fabf5497b11a656 [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001#!/bin/sh
2# ***************************************************************************
3# * _ _ ____ _
4# * Project ___| | | | _ \| |
5# * / __| | | | |_) | |
6# * | (__| |_| | _ <| |___
7# * \___|\___/|_| \_\_____|
8# *
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07009# * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070010# *
11# * This software is licensed as described in the file COPYING, which
12# * you should have received as part of this distribution. The terms
Alex Deymo8f1a2142016-06-28 14:49:26 -070013# * are also available at https://curl.haxx.se/docs/copyright.html.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070014# *
15# * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# * copies of the Software, and permit persons to whom the Software is
17# * furnished to do so, under the terms of the COPYING file.
18# *
19# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# * KIND, either express or implied.
21# *
22# ***************************************************************************
23# This shell script creates a fresh ca-bundle.crt file for use with libcurl.
24# It extracts all ca certs it finds in the local Firefox database and converts
25# them all into PEM format.
26#
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070027db=`ls -1d $HOME/.mozilla/firefox/*default*`
Lucas Eckels9bd90e62012-08-06 15:07:02 -070028out=$1
29
30if test -z "$out"; then
31 out="ca-bundle.crt" # use a sensible default
32fi
33
34currentdate=`date`
35
36cat >$out <<EOF
37##
38## Bundle of CA Root Certificates
39##
40## Converted at: ${currentdate}
41## These were converted from the local Firefox directory by the db2pem script.
42##
43EOF
44
45
46certutil -L -h 'Builtin Object Token' -d $db | \
47grep ' *[CcGTPpu]*,[CcGTPpu]*,[CcGTPpu]* *$' | \
48sed -e 's/ *[CcGTPpu]*,[CcGTPpu]*,[CcGTPpu]* *$//' -e 's/\(.*\)/"\1"/' | \
49sort | \
50while read nickname; \
51 do echo $nickname | sed -e "s/Builtin Object Token://g"; \
52eval certutil -d $db -L -n "$nickname" -a ; \
53done >> $out
54