Skip to content

Commit 7c4b4ce

Browse files
fixup! Make openssl backend work with pkcs11 certificate
On windows, sslcert and sslkey containing pkcs11 uri does not work using the openssl backend. Fixed by forcing the correct libcurl option when detecting a pkcs11 uri, much like what the curl binary is doing. Signed-off-by: Robin Courgeon <[email protected]>
1 parent e0046eb commit 7c4b4ce

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

http.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,16 +1109,32 @@ static CURL *get_curl_handle(void)
11091109
curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
11101110
ssl_cipherlist);
11111111

1112-
if (ssl_cert)
1113-
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
11141112
if (ssl_cert_type)
11151113
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, ssl_cert_type);
1114+
if (ssl_cert) {
1115+
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
1116+
if (istarts_with(ssl_cert, "pkcs11:")) {
1117+
if (ssl_cert_type && strcasecmp(ssl_cert_type, "eng")){
1118+
warning(_("Using non \"ENG\" type for a pkcs11 uri sslcert"));
1119+
}
1120+
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, "ENG");
1121+
curl_easy_setopt(result, CURLOPT_SSLENGINE, "pkcs11");
1122+
}
1123+
}
11161124
if (has_cert_password())
11171125
curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password);
1118-
if (ssl_key)
1119-
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
11201126
if (ssl_key_type)
11211127
curl_easy_setopt(result, CURLOPT_SSLKEYTYPE, ssl_key_type);
1128+
if (ssl_key) {
1129+
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
1130+
if (istarts_with(ssl_cert, "pkcs11:")) {
1131+
if (ssl_cert_type && strcasecmp(ssl_cert_type, "eng")){
1132+
warning(_("Using non \"ENG\" type for a pkcs11 uri sslkey"));
1133+
}
1134+
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, "ENG");
1135+
curl_easy_setopt(result, CURLOPT_SSLENGINE, "pkcs11");
1136+
}
1137+
}
11221138
if (ssl_capath)
11231139
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
11241140
if (ssl_pinnedkey)

0 commit comments

Comments
 (0)