X-Git-Url: https://ruderich.org/simon/gitweb/?p=tlsproxy%2Ftlsproxy.git;a=blobdiff_plain;f=src%2Ftlsproxy-setup;h=ba71e56c127381df0dc8351cd2316f15ee09b702;hp=a17b390e1f924407784a295916669f9180c10d2d;hb=7eba49d24d56288d83746f3f0ce383d7c0c36552;hpb=c98db32cbc4a3f7e4b655aacfbc503639bb8379c diff --git a/src/tlsproxy-setup b/src/tlsproxy-setup index a17b390..ba71e56 100755 --- a/src/tlsproxy-setup +++ b/src/tlsproxy-setup @@ -4,7 +4,7 @@ # # Requires certtool (from GnuTLS). # -# Copyright (C) 2011-2013 Simon Ruderich +# Copyright (C) 2011-2014 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 @@ -22,16 +22,36 @@ set -e + +if test "$#" -ge 1 && test x"$*" != 'x--force'; then + echo "Usage: $0 [--force]" >&2 + exit 1 +fi + +# Prevent accidental overwrites. +if test x"$1" != 'x--force'; then + for x in proxy-ca-key.pem proxy-ca.pem \ + proxy-key.pem proxy-invalid.pem proxy-dh.pem; do + if test -f "$x"; then + echo "File '$x' already exists. Use --force to overwrite." >&2 + exit 2 + fi + done +fi + + tempfile=`mktemp` trap 'rm -f "$tempfile"' EXIT # Generate proxy CA key file. 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" \ @@ -39,6 +59,7 @@ certtool --generate-self-signed \ # Generate proxy key file. certtool --generate-privkey \ + --sec-param high \ --outfile proxy-key.pem # Generate proxy "invalid" server certificate. It's used for problematic @@ -48,6 +69,7 @@ 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" \ @@ -55,4 +77,9 @@ certtool --generate-self-signed \ rm "$tempfile" +# Generate proxy Diffie-Hellman parameters. +certtool --generate-dh-params \ + --sec-param high \ + --outfile proxy-dh.pem + echo done