【发布时间】:2011-05-19 03:28:30
【问题描述】:
我正在尝试使用带有 OpenSSL 1.0.0d 的 cURL 7.21.1 使用 https,使用 OpenSSL 的内置 capi 引擎进行证书颁发机构检查,但它在 curl_easy_perform() 上返回 CURLE_SSL_CACERT (60)。
#include <openssl/conf.h>
#include <openssl/engine.h>
#include <openssl/ssl.h>
#define CURL_NO_OLDIES
#define CURL_STATICLIB
#include <curl.h>
// Don't forget libeay32.lib, ssleay32.lib, curl.lib
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "wldap32.lib")
#pragma comment(lib, "crypt32.lib")
int main(int argc, char* argv[])
{
OPENSSL_no_config();
ENGINE_load_capi();
// Same effect, despite ok = 1 both times:
// ENGINE* capi = ENGINE_by_id("capi");
// int ok = ENGINE_init(capi);
// ok = ENGINE_register_complete(capi);
CURLcode e = curl_global_init(CURL_GLOBAL_DEFAULT);
CURL* curl = curl_easy_init();
e = curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com/");
e = curl_easy_perform(curl); // returns CURLE_SSL_CACERT
return 0;
}
如果我使用以下配置测试“openssl s_client -connect www.google.com:443”:
openssl_conf = openssl_init
[openssl_init]
engines = engine_section
[engine_section]
capi = capi_config
[capi_config]
engine_id = capi
init=1
基于http://www.mail-archive.com/openssl-users@openssl.org/msg62249.html,我收到:
verify error:num=20:unable to get local issuer certificate
让我感到困惑的是,当我第一次编写失败的实际程序时,在我添加 ENGINE_load_capi() 之前,它有同样的失败。 我想避免使用 CA 捆绑包,因为实际程序可能在随机的公司网络中运行,而且它们可能使用私有 CA。
【问题讨论】:
-
是在windows平台上做这个吗?
-
@this.josh:是的,我知道我不能在其他平台上使用 CryptAPI,但是基于 *nix 的平台可以使用平台 ca-bundle.crt,对吗?如果没有别的,我可能最终还是会为了可靠性而捆绑它。