]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blobdiff - src/tlsproxy-setup
tlsproxy-add,tlsproxy-setup: Check for invalid argument count.
[tlsproxy/tlsproxy.git] / src / tlsproxy-setup
index 24f1e0d0767164333e102a9d0663e1589345d4d0..d76c998689454c38d004a93d304f00aa932302ee 100755 (executable)
@@ -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
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-tempfile=`mktemp` || exit 1
+set -e
 
-die() {
-    rm -f "$tempfile"
+
+if test "$#" -ne 0; then
+    echo "Usage: $0"
     exit 1
-}
+fi
+
+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 'expiration_days = 3650' >> "$tempfile"
 certtool --generate-self-signed \
          --load-privkey proxy-ca-key.pem \
          --template "$tempfile" \
-         --outfile proxy-ca.pem || die
+         --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.
@@ -48,11 +57,17 @@ 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
+         --outfile proxy-invalid.pem
 
 rm "$tempfile"
 
+# Generate proxy Diffie-Hellman parameters.
+certtool --generate-dh-params \
+         --sec-param high \
+         --outfile proxy-dh.pem
+
 echo done