X509 *issuer = NULL;
BIO *fp = NULL;
char err_buf[256]="";
- bool strict = (conn_config->verifypeer || conn_config->verifyhost);
+ bool verify_enabled = (conn_config->verifypeer || conn_config->verifyhost);
CURLcode result = CURLE_OK;
/* e.g. match issuer name with provided issuer certificate */
}
if(BIO_read_filename(fp, conn_config->issuercert) <= 0) {
- if(strict)
+ if(verify_enabled)
failf(data, "SSL: Unable to open issuer cert (%s)",
conn_config->issuercert);
result = CURLE_SSL_ISSUER_ERROR;
if(fp) {
issuer = PEM_read_bio_X509(fp, NULL, ZERO_NULL, NULL);
if(!issuer) {
- if(strict)
+ if(verify_enabled)
failf(data, "SSL: Unable to read issuer cert (%s)",
conn_config->issuercert);
result = CURLE_SSL_ISSUER_ERROR;
}
if(X509_check_issued(issuer, server_cert) != X509_V_OK) {
- if(strict)
+ if(verify_enabled)
failf(data, "SSL: Certificate issuer check failed (%s)",
conn_config->issuercert);
result = CURLE_SSL_ISSUER_ERROR;
struct Curl_easy *data,
X509 *server_cert)
{
- struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
- bool strict = (conn_config->verifypeer || conn_config->verifyhost);
BIO *mem = NULL;
struct dynbuf dname;
char err_buf[256] = "";
(void)BIO_reset(mem);
result = x509_name_oneline(X509_get_issuer_name(server_cert), &dname);
- if(result) {
- if(strict)
- failf(data, "SSL: could not get X509-issuer name");
- result = CURLE_PEER_FAILED_VERIFICATION;
+ if(result) /* should be only fatal stuff like OOM */
goto out;
- }
infof(data, " issuer: %s", curlx_dyn_ptr(&dname));
out:
struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
CURLcode result = CURLE_OK;
long ossl_verify;
- bool strict = (conn_config->verifypeer || conn_config->verifyhost);
X509 *server_cert;
bool verified = FALSE;
#ifdef USE_APPLE_SECTRUST
server_cert = SSL_get1_peer_certificate(octx->ssl);
if(!server_cert) {
- if(!strict)
+ /* no verification at all, this maybe acceptable */
+ if(!(conn_config->verifypeer || conn_config->verifyhost))
goto out;
failf(data, "SSL: could not get peer certificate");
if(result)
goto out;
}
+ /* `verifyhost` is either OK or not requested from here on */
ossl_verify = SSL_get_verify_result(octx->ssl);
ssl_config->certverifyresult = ossl_verify;
if(!verified) {
/* no trust established, report the OpenSSL status */
- failf(data, "SSL certificate OpenSSL verify result: %s (%ld)",
- X509_verify_cert_error_string(ossl_verify), ossl_verify);
- result = CURLE_PEER_FAILED_VERIFICATION;
- if(conn_config->verifypeer)
+ if(conn_config->verifypeer) {
+ failf(data, "SSL certificate OpenSSL verify result: %s (%ld)",
+ X509_verify_cert_error_string(ossl_verify), ossl_verify);
+ result = CURLE_PEER_FAILED_VERIFICATION;
goto out;
+ }
infof(data, " SSL certificate verification failed, continuing anyway!");
}