Skip to content

Commit c6a04b2

Browse files
committed
Use _toPkcs + Use/introduce _fingerprint acme.sh helper
1 parent 9e16af2 commit c6a04b2

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

acme.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,25 @@ _digest() {
10371037

10381038
}
10391039

1040+
#Usage: certpath hashalg
1041+
#Output certificate fingerprint without colons
1042+
_fingerprint() {
1043+
cert="$1"
1044+
alg="$2"
1045+
if [ -z "$alg" ]; then
1046+
_usage "Usage: _fingerprint certpath hashalg"
1047+
return 1
1048+
fi
1049+
1050+
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ] || [ "$alg" = "md5" ]; then
1051+
# openssl prints "SHA1 Fingerprint=AA:BB:CC:..."; strip prefix and colons.
1052+
${ACME_OPENSSL_BIN:-openssl} x509 -in "$cert" -noout -fingerprint -"$alg" | sed 's/.*=//; s/://g'
1053+
else
1054+
_err "$alg is not supported yet"
1055+
return 1
1056+
fi
1057+
}
1058+
10401059
#Usage: hashalg secret_hex [outputhex]
10411060
#Output binary hmac
10421061
_hmac() {

deploy/windows_rdp.sh

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,35 +70,21 @@ windows_rdp_deploy() {
7070
fi
7171
_pfx_pass="acme"
7272

73-
# ---- build PFX + thumbprint locally ------------------------------------
74-
_pfx_file="$(_mktemp)"
75-
76-
_debug "Building PFX at $_pfx_file"
77-
# Use `-certfile "$_cfullchain"` if the entire certificate chain
78-
# shall be included into the pkcs12 container. This should not
79-
# be necessary usually, since the certificates are likely in
80-
# the trust stores of the machines anyways, but we have the option
81-
# if we should need to in the future.
82-
if ! ${ACME_OPENSSL_BIN:-openssl} pkcs12 -export \
83-
-inkey "$_ckey" -in "$_ccert" \
84-
-name "acme.sh ${_cdomain}" \
85-
-passout "pass:$_pfx_pass" \
86-
-out "$_pfx_file"; then
87-
_err "Failed to build PFX archive."
88-
rm -f "$_pfx_file"
89-
return 1
90-
fi
91-
92-
# openssl prints "SHA1 Fingerprint=AA:BB:CC:..."; strip prefix and colons.
93-
_thumb="$(${ACME_OPENSSL_BIN:-openssl} x509 -in "$_ccert" -noout -fingerprint -sha1 |
94-
sed 's/.*=//; s/://g')"
73+
# ---- build thumbprint + PFX locally ------------------------------------
74+
_thumb="$(_fingerprint "$_ccert" 'sha1')"
9575
if [ -z "$_thumb" ]; then
9676
_err "Failed to compute certificate thumbprint."
97-
rm -f "$_pfx_file"
9877
return 1
9978
fi
10079
_debug "Thumbprint: $_thumb"
10180

81+
_debug "Building PFX at $_pfx_file"
82+
_pfx_file="$(_mktemp)"
83+
if ! _toPkcs "$_pfx_file" "$_ckey" "$_ccert" "$_cca" "$_pfx_pass"; then
84+
_err "Failed to build PFX archive."
85+
rm -f "$_pfx_file"
86+
return 1
87+
fi
10288
_pfx_b64=$(_base64 "multiline" <"$_pfx_file")
10389
rm -f "$_pfx_file"
10490

0 commit comments

Comments
 (0)