removing remenants of abstract unix domain socket handling, this finishes addressing...
[oweals/gnunet.git] / src / gns / gnunet-gns-proxy-setup-ca
1 #!/bin/sh
2 # This shell script will generate an X509 certificate for your gnunet-gns-proxy
3 # and install it (for both GNUnet and your browser).
4 #
5 echo "Generating CA"
6
7 options=''
8 while getopts "c:" opt; do
9   case $opt in
10     c)
11       options+="-c $OPTARG"
12       ;;
13     \?)
14       echo "Invalid option: -$OPTARG" >&2
15       exit 1
16       ;;
17     :)
18       echo "Option -$OPTARG requires an argument." >&2
19       exit 1
20       ;;
21   esac
22 done
23
24 GNSCERT=`mktemp /tmp/gnscertXXXXXX.pem`
25 GNSCAKY=`mktemp /tmp/gnscakeyXXXXXX.pem`
26 GNSCANO=`mktemp /tmp/gnscakeynoencXXXXXX.pem`
27 GNS_CA_CERT_PEM=`gnunet-config -s gns-proxy -o PROXY_CACERT -f $options`
28
29 openssl req -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=TNR/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System"
30
31 echo "Removing passphrase from key"
32 openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
33
34 cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
35
36 echo "Importing CA into browsers"
37 for f in ~/.mozilla/firefox/*.default
38 do
39   if [ -d $f ]; then
40     echo "Importing CA info Firefox $f"
41     certutil -D -n "GNS Proxy CA" -d ~/.mozilla/firefox/*.default >/dev/null 2&>1
42     certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.mozilla/firefox/*.default < $GNSCERT
43   fi
44 done
45
46 if [ -d ~/.pki/nssdb ]; then
47   echo "Importing CA into Chrome"
48   certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb >/dev/null 2&>1
49   certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb < $GNSCERT
50 fi
51
52
53 rm $GNSCAKY $GNSCANO $GNSCERT
54
55 echo "You can now start gnunet-gns-proxy and configure your browser to use a SOCKS proxy on port 7777"