mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-24 22:21:40 +00:00
This commit is contained in:
parent
bda454fe9c
commit
e07795e8f0
22
acme.sh
22
acme.sh
@ -1631,6 +1631,24 @@ _stat() {
|
||||
return 1 #error, 'stat' not found
|
||||
}
|
||||
|
||||
#keyfile
|
||||
_isRSA() {
|
||||
keyfile=$1
|
||||
if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || ${ACME_OPENSSL_BIN:-openssl} rsa -in "$keyfile" -noout -text | grep "^publicExponent:" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
#keyfile
|
||||
_isEcc() {
|
||||
keyfile=$1
|
||||
if grep "BEGIN EC PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || ${ACME_OPENSSL_BIN:-openssl} ec -in "$keyfile" -noout -text 2>/dev/null | grep "^NIST CURVE:" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
#keyfile
|
||||
_calcjwk() {
|
||||
keyfile="$1"
|
||||
@ -1644,7 +1662,7 @@ _calcjwk() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
|
||||
if _isRSA "$keyfile"; then
|
||||
_debug "RSA key"
|
||||
pub_exp=$(${ACME_OPENSSL_BIN:-openssl} rsa -in "$keyfile" -noout -text | grep "^publicExponent:" | cut -d '(' -f 2 | cut -d 'x' -f 2 | cut -d ')' -f 1)
|
||||
if [ "${#pub_exp}" = "5" ]; then
|
||||
@ -1666,7 +1684,7 @@ _calcjwk() {
|
||||
JWK_HEADER='{"alg": "RS256", "jwk": '$jwk'}'
|
||||
JWK_HEADERPLACE_PART1='{"nonce": "'
|
||||
JWK_HEADERPLACE_PART2='", "alg": "RS256"'
|
||||
elif grep "BEGIN EC PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
|
||||
elif _isEcc "$keyfile"; then
|
||||
_debug "EC key"
|
||||
crv="$(${ACME_OPENSSL_BIN:-openssl} ec -in "$keyfile" -noout -text 2>/dev/null | grep "^NIST CURVE:" | cut -d ":" -f 2 | tr -d " \r\n")"
|
||||
_debug3 crv "$crv"
|
||||
|
Loading…
Reference in New Issue
Block a user