211
211
# 2020-02-12 Fix for DUAL_RSA_ECDSA not working with ACMEv2 (#334, #474, #502)
212
212
# 2020-02-12 Fix #424 - Sporadic "error in EC signing couldn't get R from ..." (2.18)
213
213
# 2020-02-12 Fix "Registration key already in use" (2.19)
214
+ # 2020-02-13 Fix bug with copying to all locations when creating RSA and ECDSA certs (2.20)
214
215
# ----------------------------------------------------------------------------------------
215
216
216
217
PROGNAME=${0##*/ }
217
- VERSION=" 2.19 "
218
+ VERSION=" 2.20 "
218
219
219
220
# defaults
220
221
ACCOUNT_KEY_LENGTH=4096
@@ -549,8 +550,12 @@ copy_file_to_location() { # copies a file, using scp, sftp or ftp if required.
549
550
cert=$1 # descriptive name, just used for display
550
551
from=$2 # current file location
551
552
to=$3 # location to move file to.
553
+ suffix=$4 # (optional) optional suffix for DUAL_RSA_ECDSA, i.e. save to private.key becomes save to private.ec.key
552
554
IFS=\; read -r -a copy_locations <<< " $3"
553
555
for to in " ${copy_locations[@]} " ; do
556
+ if [[ -n " $suffix " ]]; then
557
+ to=" ${to% .* } .${suffix} .${to##* .} "
558
+ fi
554
559
info " copying $cert to $to "
555
560
if [[ " ${to: 0: 4} " == " ssh:" ]] ; then
556
561
debug " using scp -q $SCP_OPTS $from ${to: 4} "
@@ -1823,6 +1828,9 @@ sign_string() { # sign a string with a given key and algorithm and return urlbas
1823
1828
elif [[ " ${signed: 4: 4} " == " 0231" ]]; then # sha384 which needs trimming
1824
1829
R=$( echo " $signed " | cut -c 11-106)
1825
1830
part2=$( echo " $signed " | cut -c 107-)
1831
+ elif [[ " ${signed: 6: 4} " == " 0240" ]]; then # sha512 which needs padding
1832
+ R=$( echo -n 00; echo " $signed " | cut -c 9-138)
1833
+ part2=$( echo " $signed " | cut -c 141-)
1826
1834
elif [[ " ${signed: 6: 4} " == " 0241" ]]; then # sha512 which needs padding
1827
1835
R=$( echo -n 00; echo " $signed " | cut -c 11-140)
1828
1836
part2=$( echo " $signed " | cut -c 141-)
@@ -1846,6 +1854,8 @@ sign_string() { # sign a string with a given key and algorithm and return urlbas
1846
1854
S=$( echo " $part2 " | cut -c 5-100)
1847
1855
elif [[ " ${part2: 0: 4} " == " 0231" ]]; then # sha384
1848
1856
S=$( echo " $part2 " | cut -c 7-102)
1857
+ elif [[ " ${part2: 0: 4} " == " 0240" ]]; then # sha512 with padding
1858
+ S=$( echo -n 00; echo " $part2 " | cut -c 5-)
1849
1859
elif [[ " ${part2: 0: 4} " == " 0241" ]]; then # sha512 with padding
1850
1860
S=$( echo -n 00; echo " $part2 " | cut -c 5-)
1851
1861
elif [[ " ${part2: 0: 4} " == " 0242" ]]; then # sha512
@@ -2545,17 +2555,20 @@ if [[ "$DUAL_RSA_ECDSA" == "true" ]]; then
2545
2555
if [[ -n " $DOMAIN_CERT_LOCATION " ]]; then
2546
2556
copy_file_to_location " ec domain certificate" \
2547
2557
" ${CERT_FILE% .* } .ec.crt" \
2548
- " ${DOMAIN_CERT_LOCATION% .* } .ec.crt"
2558
+ " ${DOMAIN_CERT_LOCATION} " \
2559
+ " ec"
2549
2560
fi
2550
2561
if [[ -n " $DOMAIN_KEY_LOCATION " ]]; then
2551
- copy_file_to_location " ec private key" \
2552
- " $DOMAIN_DIR /${DOMAIN} .ec.key" \
2553
- " ${DOMAIN_KEY_LOCATION% .* } .ec.key"
2562
+ copy_file_to_location " ec private key" \
2563
+ " $DOMAIN_DIR /${DOMAIN} .ec.key" \
2564
+ " ${DOMAIN_KEY_LOCATION} " \
2565
+ " ec"
2554
2566
fi
2555
2567
if [[ -n " $CA_CERT_LOCATION " ]]; then
2556
- copy_file_to_location " ec CA certificate" \
2557
- " ${CA_CERT% .* } .ec.crt" \
2558
- " ${CA_CERT_LOCATION% .* } .ec.crt"
2568
+ copy_file_to_location " ec CA certificate" \
2569
+ " ${CA_CERT% .* } .ec.crt" \
2570
+ " ${CA_CERT_LOCATION% .* } .crt" \
2571
+ " ec"
2559
2572
fi
2560
2573
fi
2561
2574
@@ -2570,7 +2583,7 @@ if [[ -n "$DOMAIN_CHAIN_LOCATION" ]]; then
2570
2583
copy_file_to_location " full chain" " $TEMP_DIR /${DOMAIN} _chain.pem" " $to_location "
2571
2584
if [[ " $DUAL_RSA_ECDSA " == " true" ]]; then
2572
2585
cat " ${CERT_FILE% .* } .ec.crt" " ${CA_CERT% .* } .ec.crt" > " $TEMP_DIR /${DOMAIN} _chain.pem.ec"
2573
- copy_file_to_location " full chain" " $TEMP_DIR /${DOMAIN} _chain.pem.ec" " ${to_location% . * } .ec. ${to_location ##* .} "
2586
+ copy_file_to_location " full chain" " $TEMP_DIR /${DOMAIN} _chain.pem.ec" " ${to_location} " " ec "
2574
2587
fi
2575
2588
fi
2576
2589
# if DOMAIN_KEY_CERT_LOCATION is not blank, then create and copy file.
@@ -2583,8 +2596,8 @@ if [[ -n "$DOMAIN_KEY_CERT_LOCATION" ]]; then
2583
2596
cat " $DOMAIN_DIR /${DOMAIN} .key" " $CERT_FILE " > " $TEMP_DIR /${DOMAIN} _K_C.pem"
2584
2597
copy_file_to_location " private key and domain cert pem" " $TEMP_DIR /${DOMAIN} _K_C.pem" " $to_location "
2585
2598
if [[ " $DUAL_RSA_ECDSA " == " true" ]]; then
2586
- cat " $DOMAIN_DIR /${DOMAIN} .ec.key" " ${CERT_FILE% .* } .ec.crt" > " $TEMP_DIR /${DOMAIN} _K_C.pem.ec"
2587
- copy_file_to_location " private ec key and domain cert pem" " $TEMP_DIR /${DOMAIN} _K_C.pem.ec" " ${to_location% . * } .ec. ${to_location ##* .} "
2599
+ cat " $DOMAIN_DIR /${DOMAIN} .ec.key" " ${CERT_FILE% .* } .ec.crt" > " $TEMP_DIR /${DOMAIN} _K_C.pem.ec"
2600
+ copy_file_to_location " private ec key and domain cert pem" " $TEMP_DIR /${DOMAIN} _K_C.pem.ec" " ${to_location} " " ec "
2588
2601
fi
2589
2602
fi
2590
2603
# if DOMAIN_PEM_LOCATION is not blank, then create and copy file.
@@ -2598,7 +2611,7 @@ if [[ -n "$DOMAIN_PEM_LOCATION" ]]; then
2598
2611
copy_file_to_location " full key, cert and chain pem" " $TEMP_DIR /${DOMAIN} .pem" " $to_location "
2599
2612
if [[ " $DUAL_RSA_ECDSA " == " true" ]]; then
2600
2613
cat " $DOMAIN_DIR /${DOMAIN} .ec.key" " ${CERT_FILE% .* } .ec.crt" " ${CA_CERT% .* } .ec.crt" > " $TEMP_DIR /${DOMAIN} .pem.ec"
2601
- copy_file_to_location " full ec key, cert and chain pem" " $TEMP_DIR /${DOMAIN} .pem.ec" " ${to_location% . * } .ec. ${to_location ##* .} "
2614
+ copy_file_to_location " full ec key, cert and chain pem" " $TEMP_DIR /${DOMAIN} .pem.ec" " ${to_location} " " ec "
2602
2615
fi
2603
2616
fi
2604
2617
# end of copying certs.
0 commit comments