熟悉libcurl的请进!

iTom 2013-04-01 04:51:07
问个问题啊,发现有几个https居然不能正常访问,比如下面这个
curl_easy_setopt(curl, CURLOPT_URL, "https://loginchina.alibaba.com/member/signin.htm");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);打开调试,发现一直会跳转,一直跳转到127.0.0.1,返回Couldn't connect to server。
苦逼啊,其他https正常,大牛帮看看啊。
...全文
5553 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞翔的薄荷 2013-04-02
  • 打赏
  • 举报
回复
不跳转会怎么样呢? curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
ForestDB 2013-04-02
  • 打赏
  • 举报
回复
顶LS,服务器把你的请求redirect了。
mymtom 2013-04-02
  • 打赏
  • 举报
回复
HTTP 301, 302? 重定向? 楼主没有设置"User-Agent", 这是网站的防攻击措施。 curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");
iTom 2013-04-01
  • 打赏
  • 举报
回复
附上调试信息: * About to connect() to loginchina.alibaba.com port 443 (#0) * Trying 110.75.196.32... * connected * Connected to loginchina.alibaba.com (110.75.196.32) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: CN=*.alibaba.com,OU=Terms of use at www.verisign.com/rpa (c)05,OU=Research & Develop Center,O="Taobao(China) Software Co., Ltd",L=Hangzhou,ST=Zhejiang,C=CN * start date: Nov 18 00:00:00 2012 GMT * expire date: Dec 12 23:59:59 2013 GMT * common name: *.alibaba.com * issuer: CN=VeriSign Class 3 Secure Server CA - G3,OU=Terms of use at https://www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US > GET / HTTP/1.1 Host: loginchina.alibaba.com Accept: */* < HTTP/1.1 301 Moved Permanently < Date: Mon, 01 Apr 2013 01:23:01 GMT < Server: Apache < Location: https://loginchina.alibaba.com:443/member/signin.htm < Cache-Control: max-age=0 < Expires: Mon, 01 Apr 2013 01:23:01 GMT < Vary: Accept-Encoding < Content-Length: 260 < Content-Type: text/html; charset=iso-8859-1 < * Ignoring the response-body * Connection #0 to host loginchina.alibaba.com left intact * Issue another request to this URL: 'https://loginchina.alibaba.com:443/member/signin.htm' * Re-using existing connection! (#0) with host loginchina.alibaba.com * Connected to loginchina.alibaba.com (110.75.196.32) port 443 (#0) > GET /member/signin.htm HTTP/1.1 Host: loginchina.alibaba.com Accept: */* < HTTP/1.1 302 Found < Date: Mon, 01 Apr 2013 01:23:01 GMT < Server: Apache < Location: http://127.0.0.1/ < Cache-Control: max-age=0 < Expires: Mon, 01 Apr 2013 01:23:01 GMT < Vary: Accept-Encoding < Content-Length: 201 < Content-Type: text/html; charset=iso-8859-1 < X-Pad: avoid browser bug < * Ignoring the response-body * Connection #0 to host loginchina.alibaba.com left intact * Issue another request to this URL: 'http://127.0.0.1/' * About to connect() to 127.0.0.1 port 80 (#1) * Trying 127.0.0.1... * Connection refused * couldn't connect to host * Closing connection #1 * Couldn't connect to server curl_easy_perform() failed: Couldn't connect to server * Closing connection #0

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧