【发布时间】:2015-03-14 06:28:44
【问题描述】:
我正在编写一个使用 SSL 连接的 C++ 程序。证书链检查使用:
openssl 验证 -CAfile test.pem private.pem
其中 test.pem 包含中间证书和根证书。我的测试程序不验证证书链。
if ( !SSL_CTX_load_verify_locations( ctx, "c:/Certs/test.pem", NULL ) ) {
// Failure message and cleanup goes here.
}
SSL* ssl;
BIO* bio = BIO_new_ssl_connect( ctx );
BIO_get_ssl( bio, &ssl );
SSL_set_mode( ssl, SSL_MODE_AUTO_RETRY );
BIO_set_conn_hostname( bio, "url.com:https" );
if ( BIO_do_connect( bio ) <= 0 ) {
// Failure message and cleanup goes here.
}
if ( SSL_get_verify_result( ssl ) != X509_V_OK ){
// Here is where I get the error 20...
// Free all resources and exit.
}
OpenSSL 文档将错误 20 描述为:
- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:无法获取本地颁发者证书。 找不到颁发者证书:如果颁发者证书 找不到不受信任的证书。
我需要帮助来确定问题以及解决方法。我确定我拥有的证书是正确的。
【问题讨论】: