SSL: Add SSL_CTX_check_private_key in ngx_ssl_certificate.

to resolve the issue which the config test passes unexpectedly
in case of the key and cert is different the classes
(RSA/DSA/ECDSA) in each.
This commit is contained in:
u5surf 2025-02-24 15:49:24 +09:00
parent d25139db01
commit 66d19c1a47

View File

@ -553,6 +553,12 @@ ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
EVP_PKEY_free(pkey);
return NGX_ERROR;
}
if (SSL_CTX_check_private_key(ssl->ctx) == 0) {
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
"SSL_CTX_check_private_key(\"%s\") failed", key->data);
EVP_PKEY_free(pkey);
return NGX_ERROR;
}
EVP_PKEY_free(pkey);