X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftlsproxy-setup;h=4b57a2220aafd62c888c6fba8bb9be82a2ef07cf;hb=b7ce41b809a3b3533d398c0da8fd9787c149434c;hp=48a034f63afd3e0b2c3a6c84ecdeac62f5c8cc28;hpb=948878cf1d882adef61f9bd7c26473089f3032ad;p=tlsproxy%2Ftlsproxy.git diff --git a/src/tlsproxy-setup b/src/tlsproxy-setup index 48a034f..4b57a22 100755 --- a/src/tlsproxy-setup +++ b/src/tlsproxy-setup @@ -4,7 +4,7 @@ # # Requires certtool (from GnuTLS). # -# Copyright (C) 2011-2012 Simon Ruderich +# Copyright (C) 2011-2013 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,39 +20,43 @@ # along with this program. If not, see . -tempfile=`mktemp` || exit 1 +set -e -die() { - rm -f $tempfile - exit 1 -} +tempfile=`mktemp` +trap 'rm -f "$tempfile"' EXIT # Generate proxy CA key file. -certtool --generate-privkey > proxy-ca-key.pem || die +certtool --generate-privkey \ + --sec-param high \ + --outfile proxy-ca-key.pem # Generate proxy CA. -echo 'cn = tlsproxy CA' > $tempfile -echo ca >> $tempfile -echo cert_signing_key >> $tempfile +echo 'cn = tlsproxy CA' > "$tempfile" +echo ca >> "$tempfile" +echo cert_signing_key >> "$tempfile" +echo 'expiration_days = 3650' >> "$tempfile" certtool --generate-self-signed \ --load-privkey proxy-ca-key.pem \ - --template $tempfile \ - --outfile proxy-ca.pem || die + --template "$tempfile" \ + --outfile proxy-ca.pem # Generate proxy key file. -certtool --generate-privkey > proxy-key.pem || die +certtool --generate-privkey \ + --sec-param high \ + --outfile proxy-key.pem # Generate proxy "invalid" server certificate. It's used for problematic # connections. -echo 'organization = tlsproxy' > $tempfile -echo 'cn = invalid' >> $tempfile -echo tls_www_server >> $tempfile -echo encryption_key >> $tempfile -echo signing_key >> $tempfile +echo 'organization = tlsproxy' > "$tempfile" +echo 'cn = invalid' >> "$tempfile" +echo tls_www_server >> "$tempfile" +echo encryption_key >> "$tempfile" +echo signing_key >> "$tempfile" +echo 'expiration_days = 3650' >> "$tempfile" certtool --generate-self-signed \ --load-privkey proxy-key.pem \ - --template $tempfile \ - --outfile proxy-invalid.pem || die + --template "$tempfile" \ + --outfile proxy-invalid.pem -rm $tempfile +rm "$tempfile" echo done