运行 R 中的 httr 库和相互身份验证时 SSL 握手失败

SSL handshake failure when running httr library in R, and mutual authentication

我正在尝试使用 httr 库通过 https 连接到公司服务器。我有客户端证书及其受密码保护的私钥。我是 运行 以下 R 命令:

connect = httr::GET("https://someaddress:22667", config(ssl_verifypeer = 0L,  sslcert = "myCert.crt", sslkey = "mykey10.pem",keypasswd = "qwert", verbose = TRUE, sslversion = 6))

但是它失败了,出现这个错误:

failed to receive handshake, SSL/TLS connection failed

使用此 cURL 命令进行测试时:

curl -k --cert myCert.crt --key myKey10.pem https://someaddress:22667 

将建立连接。据我了解,httr 只是 cURL 的包装器(更准确地说:需要 libcurl)。当使用相同的参数时,应该建立连接。

求助!!!我花了很多时间来解决这个问题,但没有成功。

根据 R curl 库更新日志,最近有很大的修改,特别是 Windows 用户:

...

3.0 - MAJOR CHANGE ON WINDOWS: On Windows 7 / 2008-R2 and up we switch from OpenSSL to native Windows SSL (secure channel). Therefore curl now uses certificates from the windows certificate manager. This enables users on corporate/government networks to connect through enterprise proxies and such. On Windows Vista/2008 and older (including CRAN) we still use OpenSSL to guarantee TLS 1.1/1.2 support.

...

2.8.1 - Windows: switch back to OpenSSL instead of SecureChannel because Windows 2008 (CRAN) does not support TLS 1.1 and TLS 1.2 which is required for many servers now.

这可以解释原生 cURL 与其在 R 中的包装器之间的不同行为。 如果您使用的是 Windows,那么,请通过选择另一个版本(2.8.1 或 3.0 或 3.1,我们看到日志中的大变化):

library(curl)
sessionInfo()
other attached packages:
[1] curl_3.1

R CMD REMOVE curl
wget http://cran.univ-paris1.fr/src/contrib/Archive/curl/curl_2.8.1.tar.gz
R CMD INSTALL curl_2.8.1.tar.gz

curl 档案是 here

请给我反馈这个答案,我花了时间。