【问题标题】:Libcurl no support for https but curl doesLibcurl 不支持 https 但 curl 支持
【发布时间】:2022-03-03 16:46:01
【问题描述】:

当我运行curl -V 时,我的输出是这样的

curl 7.82.0-DEV (x86_64-pc-win32) libcurl/7.82.0-DEV OpenSSL/1.1.1m WinIDN
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI UnixSockets alt-svc

显然有Https。当我通过 c++ 使用它时,使用curl_version_info_data

curl_version_info_data* ver = curl_version_info(CURLVERSION_NOW);
    for (int i = 0; i < 14; ++i) {
        cout << ver->protocols[i] << endl;
    }

列出的支持的协议是

dict
file
ftp
gopher
http
imap
ldap
mqtt
pop3
rtsp
smb
smtp
telnet
tftp

如果我尝试使用 https,则会收到错误 Unsupported protocol。有人有什么想法吗?

【问题讨论】:

  • 取另一个 libcurl。
  • 你是如何编译和链接的? OpenSSL 肯定是由一个单独的库提供的。因此,如果未激活 OpenSSL,libcurl 可能会丢弃 ftps、https 等。仅供参考:Building libcurl with SSL support on Windowsgoogle "libcurl openssl" 你自己。
  • @Scheff'sCat 下载 OpenSSL 作为二进制文件并安装,使用 WITH_DEVEL 链接。但是我很困惑,使用 WINSSL 的构建也说 https 可用但它不可用?
  • 请显示失败代码的minimal reproducible example。为什么只打印 14 个协议? curl 命令行是否使用与您的应用程序相同的 libcurl?

标签: c++ curl


【解决方案1】:

我想通了,在运行时,我尝试通过从 Curl 的预编译版本中获取 libcurl.liblibcurl_imp.lib 来修复(我安装了两个版本)。预编译版本不支持 https。我在这里阅读了常见问题解答https://curl.se/docs/faq.html 并正确链接了静态库。之后,它运行良好。

【讨论】:

    猜你喜欢
    • 2016-08-23
    • 1970-01-01
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    相关资源
    最近更新 更多