wolfssl: load certificate *chain* for PEM client certs

Closes #12634
This commit is contained in:
Lealem Amedie 2024-01-05 13:12:53 -07:00 committed by Daniel Stenberg
parent 8e2d7b9fa4
commit afdb6c2d34
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -583,12 +583,25 @@ wolfssl_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
if(ssl_config->primary.clientcert && ssl_config->key) {
int file_type = do_file_type(ssl_config->cert_type);
if(wolfSSL_CTX_use_certificate_file(backend->ctx,
ssl_config->primary.clientcert,
file_type) != 1) {
failf(data, "unable to use client certificate (no key or wrong pass"
" phrase?)");
return CURLE_SSL_CONNECT_ERROR;
if(file_type == WOLFSSL_FILETYPE_PEM) {
if(wolfSSL_CTX_use_certificate_chain_file(backend->ctx,
ssl_config->primary.clientcert)
!= 1) {
failf(data, "unable to use client certificate");
return CURLE_SSL_CONNECT_ERROR;
}
}
else if(file_type == WOLFSSL_FILETYPE_ASN1) {
if(wolfSSL_CTX_use_certificate_file(backend->ctx,
ssl_config->primary.clientcert,
file_type) != 1) {
failf(data, "unable to use client certificate");
return CURLE_SSL_CONNECT_ERROR;
}
}
else {
failf(data, "unknown cert type");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
file_type = do_file_type(ssl_config->key_type);