Browse Source

Fix CHECK_REMOTE for DUAL_RSA_ECDSA

pull/572/head
Tim Kimber 6 years ago
parent
commit
89036c126b
No known key found for this signature in database GPG Key ID: 3E1804964E76BD18
1 changed files with 28 additions and 9 deletions
  1. +28
    -9
      getssl

+ 28
- 9
getssl View File

@ -2561,9 +2561,14 @@ fi
# if check_remote is true then connect and obtain the current certificate (if not forcing renewal)
if [[ "${CHECK_REMOTE}" == "true" ]] && [[ $_FORCE_RENEW -eq 0 ]]; then
debug "getting certificate for $DOMAIN from remote server"
if [[ "$DUAL_RSA_ECDSA" == "true" ]]; then
CIPHER="-cipher RSA"
else
CIPHER=""
fi
# shellcheck disable=SC2086
EX_CERT=$(echo \
| openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:${REMOTE_PORT}" ${REMOTE_EXTRA} 2>/dev/null \
| openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:${REMOTE_PORT}" ${REMOTE_EXTRA} ${CIPHER} 2>/dev/null \
| openssl x509 2>/dev/null)
if [[ -n "$EX_CERT" ]]; then # if obtained a cert
if [[ -s "$CERT_FILE" ]]; then # if local exists
@ -2817,16 +2822,30 @@ fi
# Check if the certificate is installed correctly
if [[ ${CHECK_REMOTE} == "true" ]]; then
sleep "$CHECK_REMOTE_WAIT"
# shellcheck disable=SC2086
CERT_REMOTE=$(echo \
| openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:${REMOTE_PORT}" ${REMOTE_EXTRA} 2>/dev/null \
| openssl x509 -noout -fingerprint 2>/dev/null)
CERT_LOCAL=$(openssl x509 -noout -fingerprint < "$CERT_FILE" 2>/dev/null)
if [[ "$CERT_LOCAL" == "$CERT_REMOTE" ]]; then
info "${DOMAIN} - certificate installed OK on server"
if [[ "$DUAL_RSA_ECDSA" == "true" ]]; then
PARAMS=("-cipher RSA" "-cipher ECDSA")
CERTS=("$CERT_FILE" "${CERT_FILE%.*}.ec.crt")
TYPES=("rsa" "$PRIVATE_KEY_ALG")
else
error_exit "${DOMAIN} - certificate obtained but certificate on server is different from the new certificate"
PARAMS=("")
CERTS=("$CERT_FILE")
TYPES=("$PRIVATE_KEY_ALG")
fi
for ((i=0; i<${#PARAMS[@]};++i)); do
debug "Checking ${CERTS[i]}"
# shellcheck disable=SC2086
CERT_REMOTE=$(echo \
| openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:${REMOTE_PORT}" ${REMOTE_EXTRA} ${PARAMS[i]} 2>/dev/null \
| openssl x509 -noout -fingerprint 2>/dev/null)
CERT_LOCAL=$(openssl x509 -noout -fingerprint < "${CERTS[i]}" 2>/dev/null)
if [[ "$CERT_LOCAL" == "$CERT_REMOTE" ]]; then
info "${DOMAIN} - ${TYPES[i]} certificate installed OK on server"
else
info "${CERTS[i]} didn't match server"
error_exit "${DOMAIN} - ${TYPES[i]} certificate obtained but certificate on server is different from the new certificate"
fi
done
fi
# end of Check if the certificate is installed correctly


Loading…
Cancel
Save