2 # This shell script will generate an X509 certificate for your gnunet-gns-proxy
3 # and install it (for both GNUnet and your browser).
6 # TODO: We should sed the real paths to the binaries involved here.
8 if ! which certutil > /dev/null
10 echo "'certutil' command not found. Please install it."
14 if ! which openssl > /dev/null
16 echo "'openssl' command not found. Please install it."
23 while getopts "c:" opt; do
26 options="$options -c $OPTARG"
29 echo "Invalid option: -$OPTARG" >&2
33 echo "Option -$OPTARG requires an argument." >&2
39 GNSCERT=`mktemp /tmp/gnscertXXXXXX.pem`
40 GNSCAKY=`mktemp /tmp/gnscakeyXXXXXX.pem`
41 GNSCANO=`mktemp /tmp/gnscakeynoencXXXXXX.pem`
42 GNS_CA_CERT_PEM=`gnunet-config -s gns-proxy -o PROXY_CACERT -f $options`
43 mkdir -p `dirname $GNS_CA_CERT_PEM`
45 openssl req -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System"
47 echo "Removing passphrase from key"
48 openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
50 echo "Making private key available to gnunet-gns-proxy"
51 cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
53 echo "Importing CA into browsers"
54 for f in ~/.mozilla/firefox/*.*/
57 echo "Importing CA info Firefox at $f"
58 # delete old certificate (if any)
59 certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null
61 certutil -A -n "GNS Proxy CA" -t CT,, -d "$f" < $GNSCERT
65 if [ -d ~/.pki/nssdb/ ]; then
66 echo "Importing CA into Chrome at ~/.pki/nssdb/"
67 # delete old certificate (if any)
68 certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null
70 certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb/ < $GNSCERT
74 rm -f $GNSCAKY $GNSCANO $GNSCERT
76 echo "==================================="
77 echo "You can now start gnunet-gns-proxy."
78 echo "Afterwards, configure your browser "
79 echo " to use a SOCKS proxy on port 7777."
80 echo "==================================="