Skip to content

FIX pkcs11 uri with openssl backend #5648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,16 +1109,32 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
ssl_cipherlist);

if (ssl_cert)
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
if (ssl_cert_type)
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, ssl_cert_type);
if (ssl_cert) {
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
if (istarts_with(ssl_cert, "pkcs11:")) {
if (ssl_cert_type && strcasecmp(ssl_cert_type, "eng")){
warning(_("Using non \"ENG\" type for a pkcs11 uri sslcert"));
}
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, "ENG");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read this correctly, then ssl_cert_type is overridden here. I am not familiar enough with PKCS11 to know whether that's appropriate or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a technical perspective, the curl_easy_setopt says it ok to set an option several times.
On the functional level, this does silently override a property which might not be acceptable for git mainteners

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that a check whether ssl_cert_type is either unset, or already contains ENG, would be needed, and if neither is the case a warning should be issued.

curl_easy_setopt(result, CURLOPT_SSLENGINE, "pkcs11");
}
}
if (has_cert_password())
curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password);
if (ssl_key)
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
if (ssl_key_type)
curl_easy_setopt(result, CURLOPT_SSLKEYTYPE, ssl_key_type);
if (ssl_key) {
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
if (istarts_with(ssl_cert, "pkcs11:")) {
if (ssl_cert_type && strcasecmp(ssl_cert_type, "eng")){
warning(_("Using non \"ENG\" type for a pkcs11 uri sslkey"));
}
curl_easy_setopt(result, CURLOPT_SSLCERTTYPE, "ENG");
curl_easy_setopt(result, CURLOPT_SSLENGINE, "pkcs11");
}
}
if (ssl_capath)
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
if (ssl_pinnedkey)
Expand Down
Loading