首页 > 解决方案 > 从 Windows PC 向 https url 发布 json 请求时出现 SSL 连接错误的原因可能是什么?

问题描述

我在 Visual Studio 中将 libcurl.dll 版本 7.72.0.0 用于 C++ 应用程序。

当我在一台带有 Service Pack 1 的 Windows 7 PC 上向 HTTPS url 发布 JSON 请求时,请求已成功发布。但是在与 Windows 7 Service Pack 1 具有相同操作系统的其他 PC 上,我从以下位置获得响应代码 35 curl_easy_perform():SSL 连接错误。

相同的 C++ 代码在一台 Windows 7 PC 上运行而在另一台 Windows 7 PC 上出现错误的原因可能是什么?两台电脑都在同一个网络上。

以下是 C++ 代码:

curl_easy_setopt(curl, CURLOPT_URL, Url.c_str());

curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
 
// send all data to this function  
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
 
// we pass our 'chunk' struct to the callback function 
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&sResponse);
 
//some servers don't like requests that are made without a user-agent
//  field, so we provide one
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
 
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
printf("\npostthisData=%s\n", postthis);
        
if (itsHTTPSRequest)
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);

// if we don't provide POSTFIELDSIZE, libcurl will strlen() by
//   itself 
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));

curl_easy_setopt( curl, CURLOPT_CONNECTTIMEOUT, m_RWTimeOut );
curl_easy_setopt( curl, CURLOPT_LOW_SPEED_TIME, m_RWTimeOut);
curl_easy_setopt( curl, CURLOPT_LOW_SPEED_LIMIT, 30L);

标签: c++windowsvisual-studio-2013libcurltls1.2

解决方案


推荐阅读