aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/gnunet-gns-proxy-setup-ca.in191
1 files changed, 14 insertions, 177 deletions
diff --git a/src/gns/gnunet-gns-proxy-setup-ca.in b/src/gns/gnunet-gns-proxy-setup-ca.in
index da0175594..59dc69da9 100644
--- a/src/gns/gnunet-gns-proxy-setup-ca.in
+++ b/src/gns/gnunet-gns-proxy-setup-ca.in
@@ -50,8 +50,8 @@ progname=${0##*/}
50 50
51setdefaults() 51setdefaults()
52{ 52{
53 verbosity=0
53 runcmd= 54 runcmd=
54 #TOP=$( (exec pwd -P 2>/dev/null) || (exec pwd 2>/dev/null) )
55} 55}
56 56
57statusmsg() 57statusmsg()
@@ -61,7 +61,9 @@ statusmsg()
61 61
62infomsg() 62infomsg()
63{ 63{
64 statusmsg "INFO: $@" 64 if [ $verbosity = 1 ]; then
65 statusmsg "INFO: $@"
66 fi
65} 67}
66 68
67warningmsg() 69warningmsg()
@@ -79,58 +81,6 @@ linemsg()
79 statusmsg "=========================================" 81 statusmsg "========================================="
80} 82}
81 83
82# Given a variable name in $1, modify the variable in place
83# as follows:
84# Convert possibly-relative path to absolute path by prepending
85# ${TOP} if necessary. Also delete trailing "/", if any.
86resolvepath()
87{
88 local var="$1"
89 local val
90 eval val=\"\${${var}}\"
91 case "${val}" in
92 /)
93 ;;
94 /*)
95 val="${val%/}"
96 ;;
97 *)
98 val="${TOP}/${val%/}"
99 ;;
100 esac
101 eval ${var}=\"\${val}\"
102}
103
104# usage()
105# {
106# if [ -n "$*" ]; then
107# echo ""
108# echo "${progname}: $*"
109# fi
110# cat <<_usage_
111
112# Usage: ${progname} [-fhv] [-c FILE] operation [...]
113
114# Operations:
115# cert Create the GNS certificate and only insert
116# it in GNS.
117# browser Create the GNS certificate, insert it in
118# GNS and install it in webbrowsers found.
119# all Create the GNS certificate, insert it in
120# GNS and install it in webbrowsers found.
121# help Print this help message.
122
123# Options:
124# -c FILE Use the configuration file FILE.
125# -f Perform expansions of the variables used in the config
126# value of gns-proxy. This will usually expand
127# $GNUNET_DATA_HOME to represent its path.
128# -h Print this help message.
129# -v Print the version.
130
131# _usage_
132# exit 1
133# }
134 84
135usage() 85usage()
136{ 86{
@@ -153,78 +103,6 @@ _usage_
153} 103}
154 104
155 105
156# parseoptions()
157# {
158# opts=':cfhv'
159# # For now use POSIX getopts. For the future, refer to
160# # the shell capabilities check build.sh has?
161# if type getopts >/dev/null 2>&1; then
162# # we are a posix shell, we can use the builtin getopts
163# getoptcmd='getopts ${opts} opt && opt=-${opt}'
164# optargcmd=':'
165# optremcmd='shift $((${OPTIND} -1))'
166# fi
167
168# # parse command line options.
169# while eval ${getoptcmd}; do
170# case ${opt} in
171
172# -c)
173# eval ${optargcmd}; resolvepath OPTARG
174# GNUNET_CONFIG_FILE="${OPTARG}"
175# export GNUNET_CONFIG_FILE
176# ;;
177# -v)
178# print_version
179# ;;
180# --)
181# break
182# ;;
183# -'?'|-h)
184# usage
185# ;;
186# esac
187# done
188
189# # operations
190# eval ${optremcmd}
191# while [ $# -gt 0 ]; do
192# op=$1; shift
193# operations="${operations} ${op}"
194# case "${op}" in
195# help)
196# usage
197# ;;
198# all|\
199# browser|\
200# cert)
201# ;;
202# *)
203# usage "Unknown operation \`${op}'"
204# ;;
205# esac
206# op="$( echo "$op" | tr -s '.-' '__')"
207# eval do_${op}=true
208# done
209# }
210 #[ -n "${operations}" ] || usage "Missing operation to perform."
211 # old code:
212 # while getopts "c:" opt; do
213 # case $opt in
214 # c)
215 # options="$options -c $OPTARG"
216 # ;;
217 # \?)
218 # echo "Invalid option: -$OPTARG" >&2
219 # exit 1
220 # ;;
221 # :)
222 # echo "Option -$OPTARG requires an argument." >&2
223 # exit 1
224 # ;;
225 # esac
226 # done
227
228generate_ca() 106generate_ca()
229{ 107{
230 echo "" 108 echo ""
@@ -238,15 +116,6 @@ generate_ca()
238 # This warning is mostly pointless. 116 # This warning is mostly pointless.
239 warning "You need to export the TMPDIR variable" 117 warning "You need to export the TMPDIR variable"
240 fi 118 fi
241 # else
242 # # SETUP_TMPDIR="$HOME/gns_setup"
243 # # if [ ! -e "$SETUP_TMPDIR" ]; then
244 # # mkdir -p $SETUP_TMPDIR
245 # # fi
246 # GNSCERT=`mktemp ${00##*/}.pem` || exit 1
247 # GNSCAKY=`mktemp ${00##*/}.pem` || exit 1
248 # GNSCANO=`mktemp ${00##*/}.pem` || exit 1
249 # fi
250 119
251 # # ------------- gnutls 120 # # ------------- gnutls
252 # 121 #
@@ -280,18 +149,12 @@ generate_ca()
280 GNS_CA_CERT_PEM=`gnunet-config ${GNUNET_CONFIG} -s gns-proxy -o PROXY_CACERT -f ${options}` 149 GNS_CA_CERT_PEM=`gnunet-config ${GNUNET_CONFIG} -s gns-proxy -o PROXY_CACERT -f ${options}`
281 mkdir -p `dirname $GNS_CA_CERT_PEM` 150 mkdir -p `dirname $GNS_CA_CERT_PEM`
282 151
283 # Bad names etc. 152 openssl req -config $OPENSSLCFG -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"
284 if [ verbosity ]; then
285 VERBOSE_OUTPUT=""
286 else
287 VERBOSE_OUTPUT="2>/dev/null"
288 fi
289 openssl req -config $OPENSSLCFG -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" ${VERBOSE_OUTPUT}
290 153
291 statusmsg "Removing passphrase from key" 154 infomsg "Removing passphrase from key"
292 openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO ${VERBOSE_OUTPUT} 155 openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
293 156
294 statusmsg "Making private key available to gnunet-gns-proxy" 157 infomsg "Making private key available to gnunet-gns-proxy"
295 cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM 158 cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
296} 159}
297 160
@@ -307,12 +170,12 @@ importbrowsers()
307 warningmsg "Not importing into browsers." 170 warningmsg "Not importing into browsers."
308 warningmsg "For 'certutil' install nss." 171 warningmsg "For 'certutil' install nss."
309 else 172 else
310 statusmsg "Importing CA into browsers" 173 infomsg "Importing CA into browsers"
311 # TODO: Error handling? 174 # TODO: Error handling?
312 for f in ~/.mozilla/firefox/*.*/ 175 for f in ~/.mozilla/firefox/*.*/
313 do 176 do
314 if [ -d $f ]; then 177 if [ -d $f ]; then
315 statusmsg "Importing CA into Firefox at $f" 178 infomsg "Importing CA into Firefox at $f"
316 # delete old certificate (if any) 179 # delete old certificate (if any)
317 certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null 180 certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null
318 # add new certificate 181 # add new certificate
@@ -321,7 +184,7 @@ importbrowsers()
321 done 184 done
322 # TODO: Error handling? 185 # TODO: Error handling?
323 if [ -d ~/.pki/nssdb/ ]; then 186 if [ -d ~/.pki/nssdb/ ]; then
324 statusmsg "Importing CA into Chrome at ~/.pki/nssdb/" 187 infomsg "Importing CA into Chrome at ~/.pki/nssdb/"
325 # delete old certificate (if any) 188 # delete old certificate (if any)
326 certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null 189 certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null
327 # add new certificate 190 # add new certificate
@@ -345,9 +208,9 @@ clean_up()
345 fi 208 fi
346 209
347 linemsg 210 linemsg
348 infomsg "You can now start gnunet-gns-proxy." 211 statusmsg "You can now start gnunet-gns-proxy."
349 infomsg "Afterwards, configure your browser " 212 statusmsg "Afterwards, configure your browser "
350 infomsg "to use a SOCKS proxy on port 7777. " 213 statusmsg "to use a SOCKS proxy on port 7777. "
351 linemsg 214 linemsg
352} 215}
353 216
@@ -383,32 +246,6 @@ main()
383 generate_ca 246 generate_ca
384 importbrowsers 247 importbrowsers
385 clean_up 248 clean_up
386
387# Needs debugging...
388# setdefaults
389# _args=$@
390# parseoptions "$@"
391# for op in ${operations}; do
392# case "${op}" in
393# cert)
394# ${runcmd} "${generate_ca}"
395# ${runcmd} "${clean_up}"
396# ;;
397# browser)
398# ${runcmd} "${generate_ca}"
399# ${runcmd} "${importbrowsers}"
400# ${runcmd} "${clean_up}"
401# ;;
402# all)
403# ${runcmd} "${generate_ca}"
404# ${runcmd} "${importbrowsers}"
405# ${runcmd} "${clean_up}"
406# ;;
407# *)
408# infomsg "Unknown operation \`${op}'"
409# ;;
410# esac
411# done
412} 249}
413 250
414main "$@" 251main "$@"