当我运行这段代码时,我得到了错误信息:
- 即将连接()到10.12.190.155端口443 (#0)
- 尝试10.12.190.155……*连接
- 连接到10.12.190.155(10.12.190.155)端口443 (#0)
- 使用certpath: sql:/etc/pki/nssdb初始化NSS
- CAfile:/home/wh/work/sslkey/ca.crtCApath:没有
- 无法加载客户端密钥-8178.
- NSS错误-8178
- 关闭连接#0
- 本地SSL证书问题
旋度*旋度;CURLcode res;
//static const char *pClientCert = "/home/wh/work/sslkey/user1.pem";
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, "https://10.12.190.155/");
curl_easy_setopt(curl, CURLOPT_CAINFO, "/home/wh/work/sslkey/ca.crt");
curl_easy_setopt(curl,CURLOPT_SSLCERT,"/home/wh/work/sslkey/user1.pem");
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %sn",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
curl_global_cleanup();
代码中没有curl_easy_setopt(curl, CURLOPT_SSLKEY, "key_file_path");
来获取密钥。也不清楚您的user1。Pem是否同时包含密钥和证书?
如果答案是no,则需要提供密钥。使用上述命令创建Pem文件。如果您从。p12文件转换密钥,那么也检查此问题。