X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftlsproxy-add;h=c838a9a35980c5a1ff5d26ab467287d75ac29960;hb=2e96ede8aa7a32d840fa62fd8c4520960b69348d;hp=be8cb8a002b392d1795c2d39f1da5037601d6e6e;hpb=d778944d0403b093d43d9cbd94bd298bfc3a8d42;p=tlsproxy%2Ftlsproxy.git
diff --git a/src/tlsproxy-add b/src/tlsproxy-add
index be8cb8a..c838a9a 100755
--- a/src/tlsproxy-add
+++ b/src/tlsproxy-add
@@ -20,7 +20,9 @@
# along with this program. If not, see .
-if [ "x$1" = x ]; then
+set -e
+
+if test "$#" -eq 0; then
echo "Usage: $0 []"
echo
echo "Add the server certificate (as .pem file) for "
@@ -38,12 +40,8 @@ if [ "x$1" = x ]; then
exit 1
fi
-tempfile=`mktemp` || exit 1
-
-die() {
- rm -f "$tempfile"
- exit 1
-}
+tempfile=`mktemp`
+trap 'rm -f "$tempfile"' EXIT
# Generate server certificate for given host.
echo 'organization = tlsproxy' > "$tempfile"
@@ -51,16 +49,17 @@ echo "cn = $1" >> "$tempfile"
echo tls_www_server >> "$tempfile"
echo encryption_key >> "$tempfile"
echo signing_key >> "$tempfile"
+echo 'expiration_days = 3650' >> "$tempfile"
certtool --generate-certificate \
--load-privkey proxy-key.pem \
--load-ca-certificate proxy-ca.pem \
--load-ca-privkey proxy-ca-key.pem \
--template "$tempfile" \
- --outfile "certificate-$1-proxy.pem" || die
+ --outfile "certificate-$1-proxy.pem"
rm "$tempfile"
-if [ "x$2" = x ]; then
- echo please enter server certificate
+if test "x$2" = x; then
+ echo 'Please enter server certificate (Ctrl-D to terminate input).'
cat > "certificate-$1-server.pem"
else
cp "$2" "certificate-$1-server.pem"