curl_easy_perform() 失败:SSL 对等证书或 SSH 远程密钥不正常
curl_easy_perform() failed: SSL peer certificate or SSH remote key was not OK
运行此代码时出现错误"curl_easy_perform(( 失败:SSL 对等证书或 SSH 远程密钥不正常">
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL* curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, "https://www.quandl.com/api/v3/datasets/WIKI/FB/data.json?api_key=MY-CODE-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_perform() failed: %sn", curl_easy_strerror(res));
}
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
Quandl 网站上有一个使用这个确切 GET 请求的示例。虽然它正在使用卷曲.exe但我认为它与此无关。
Quandl 网站上没有任何地方提到如何获取证书或密钥,所以我最初的想法是他们不允许直接使用 libcurl 或 curl.exe从 quandl 服务器检索一些证书。
我也尝试了 google.com 并得到了同样的错误。
有人遇到过这个吗?
编辑
我不想绕过 SSL 验证。
我发现您需要在此处下载.pem文件 https://curl.haxx.se/docs/caextract.html
并添加这些设置...
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1);
curl_easy_setopt(curl, CURLOPT_CAINFO, "PATH TO FILE\cacert.pem");
curl_easy_setopt(curl, CURLOPT_CAPATH, "PATH TO FILE\cacert.pem");
相关文章:
- SSH通过/sbin/SSH无法读取RSA密钥文件(从控制台运行)
- 允许从 std::map 的密钥窃取资源?
- TMap::Emplace() 在应用现有密钥时会覆盖吗?
- 在没有密钥的情况下读取密文的剩余噪声预算
- 如何修复无效的API密钥,IP或操作权限错误?
- 所有可能的链接生成器与64位密钥
- 如何在unordered_map中更改密钥?
- 获取当前密钥状态?
- curl_easy_perform() 失败:SSL 对等证书或 SSH 远程密钥不正常
- 将密钥发送到非前台的游戏窗口
- 有哪些方法可以对基于 256 位密钥的矩阵进行加扰?
- 如何在精灵表上的两个不同部分之间来回切换,同时用户仍使用 SFML 持有密钥
- 如何将CNG密钥转换为OpenSSL EVP_PKEY(反之亦然)?
- 运行密钥密码解密知道密钥?
- std::unordered_map 运算符 [] 是否对非现有密钥进行零初始化?
- 封装 std::map 以允许迭代,但没有直接密钥访问?
- SSH公共密钥身份验证,使用libssh2 C
- CURL SSH密钥密码安全
- tbb::concurrent_hash_map-如果密钥条目被其他线程阻止,如何返回
- ssl对端证书或ssh远程密钥不正确