-fix check for DANE and ftbfs
[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 mkdir -p `dirname $GNS_CA_CERT_PEM`
29
30 openssl req -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System"
31
32 echo "Removing passphrase from key"
33 openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
34
35 cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
36
37 echo "Importing CA into browsers"
38 for f in ~/.mozilla/firefox/*.default
39 do
40   if [ -d $f ]; then
41     echo "Importing CA info Firefox $f"
42     certutil -D -n "GNS Proxy CA" -d ~/.mozilla/firefox/*.default >/dev/null 2&>1
43     certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.mozilla/firefox/*.default < $GNSCERT
44   fi
45 done
46
47 if [ -d ~/.pki/nssdb ]; then
48   echo "Importing CA into Chrome"
49   certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb >/dev/null 2&>1
50   certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb < $GNSCERT
51 fi
52
53
54 rm $GNSCAKY $GNSCANO $GNSCERT
55
56 echo "You can now start gnunet-gns-proxy and configure your browser to use a SOCKS proxy on port 7777"