【发布时间】:2016-12-02 15:05:08
【问题描述】:
我遇到了关于 CURL 和 SSL 的错误,我不知道发生了什么。
我已经更新了所有可能的包并成功地从其他 HTTPS 请求中获得响应。我在 Windows 7 和 10 上试过。
这段代码有什么问题?
u <-"https://www.receita.fazenda.gov.br/Aplicacoes/SSL/ATCTA/CPF/ConsultaPublica.asp"
curl::curl_fetch_memory(u, new_handle(verbose=T))
* timeout on name lookup is not supported
* Hostname in DNS cache was stale, zapped
* Trying 161.148.231.100...
* TCP_NODELAY set
* Connected to www.receita.fazenda.gov.br (161.148.231.100) port 443 (#3)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: C:/Users/athos.damiani/Documents/R/R-3.3.2/etc/curl-ca-bundle.crt
CApath: none
* Unknown SSL protocol error in connection to www.receita.fazenda.gov.br:443
* Curl_http_done: called premature == 1
* stopped the pause stream!
* Closing connection 3
Error in curl::curl_fetch_memory(u, new_handle(verbose = T)) :
SSL connect error
我的 sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] curl_2.3 httr_1.2.1
loaded via a namespace (and not attached):
[1] R6_2.2.0 tools_3.3.2
谢谢!
【问题讨论】:
-
您可以尝试
curl::curl_fetch_memory(u, new_handle(verbose=TRUE, ssl_verifyhost=FALSE, ssl_verifypeer=FALSE))(这是非常不安全的),但正如@froderik 指出的那样,该站点还有其他问题,因为该调用的结果是@987654324 @. -
@hrbrmstr 试过了,但没有运气。一个新信息:我设法在命令行(在 R 之外)中获取它。有什么提示吗?
-
当我在命令行上使用
curl(无选项)尝试它时,我收到 SSL 证书警告。当我使用curl --insecure(模仿我在 R 中建议的选项)时,我得到了 HTML,但最后我也得到了curl: (56) SSLRead() return error -9806。 -
不幸的是
RCurl::getURL("https://www.receita.fazenda.gov.br/Aplicacoes/SSL/ATCTA/CPF/ConsultaPublica.asp", .opts=list(ssl.verifypeer=0, failonerror=0))也做了同样的事情。 -
嗯,这很奇怪。我的 curl 无法识别 -insecure 参数。我正在使用 curl 7.51.0。