aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-12-09 01:02:27 +0100
committerGuilhem Moulin <guilhem@fripost.org>2015-12-09 01:02:27 +0100
commit73a9239019b7dd3ace938f9bd4766cf0dabec6fd (patch)
tree6b9ea3f1268962911ce7b86837653d9f6171a838
parent8eb679e08e08b4bb992c8d43f57c3458aab4cf1a (diff)
Add an option --chain[=FILE].
-rwxr-xr-xletsencrypt19
1 files changed, 15 insertions, 4 deletions
diff --git a/letsencrypt b/letsencrypt
index 7465378..593ab8f 100755
--- a/letsencrypt
+++ b/letsencrypt
@@ -17,7 +17,7 @@ declare COMMAND ACCOUNTKEY
declare -l GENKEY
declare RUNAS QUIET= DEBUG=
-declare SRVCRT= CHAIN= CSR SRVKEY
+declare SRVCRT= CHAIN CSR SRVKEY
declare -i MIN_AGE=0
declare -l HASH=
declare SUBJECT=/
@@ -62,8 +62,8 @@ usage() {
--san=STRING Comma-separated list of Subject Alternative Names formatted as "type:value"
--keyusage=STRING Comma-separated list of Key Usages, see x509v3_config(5ssl)
(default: "digitalSignature,keyEncipherment,keyCertSign")
- --chain Store not only the server certificate in the file specified with --output, but
- also the CA's
+ --chain[=FILE] Store the server certificate along with its intermediate CA in FILE; if FILE is
+ empty or omitted, use the file specified with --output
--min-age=SECONDS Don't do anything if the certificate specified by --output exists and its expiration
is more than SECONDS ahead.
--output=FILE Where to store the issued (signed) X.509 certificate
@@ -102,7 +102,8 @@ while [ $# -gt 0 ]; do
--output=*) SRVCRT="${1#*=}";;
--min-age=*) MIN_AGE="${1#*=}";;
- --chain) CHAIN=1;;
+ --chain) CHAIN=;;
+ --chain=*) CHAIN="${1#*=}";;
--csr=*) CSR="${1#*=}";;
--key=*) SRVKEY="${1#*=}";;
--hash=*) HASH="${1#*=}";;
@@ -295,6 +296,16 @@ if [ "$COMMAND" = 'new-cert' ]; then
cat "$x509" >"$SRVCRT"
[ ! "$DEBUG" ] || openssl x509 -noout -text <"$SRVCRT"
+ # add the CA chain
+ if [ ${CHAIN+x} ]; then
+ if [ "${CHAIN:-$SRVCRT}" = "$SRVCRT" ]; then
+ cat "$CAfile" >>"$SRVCRT"
+ else
+ [ -e "$CHAIN" ] || touch "$CHAIN"
+ cat "$SRVCRT" "$CAfile" >"$CHAIN"
+ fi
+ fi
+
if [ ! "$QUIET" ]; then
echo "X.509 certificate $SRVCRT has been updated or renewed"
echo