我在SOAPUI中有一个成功的SOAP请求,我正在尝试使用httr
包将其转换为R代码。在SOAPUI中,我要做的所有SSL设置都是提供一个指向KeyStore的PKCS#12文件的文件路径,然后为PKCS#12文件提供一个纯文本密码作为KeyStore密码。通过此设置,一切正常。
在R中,由于httr
使用curl
,据我了解,我需要从捆绑的PKCS#12文件中提取客户端SSL证书和SSL密钥作为两个.pem
文件。因此,我使用以下OpenSSL命令提取了它们:
openssl pkcs12 -in "path to .p12 file" -passin pass:******** -clcerts -nokeys -out "path to new cert.pem"
openssl pkcs12 -in "path to .p12 file" -passin pass:******** -nodes -nocerts -out "path to new key.pem"
然后,在我的httr::POST
请求中,我包括了此config
选项以指向.pem
文件,以便可以正确定义卷曲手柄(我只是临时设置了ssl_verifypeer = F
,所以我可以消除由于CA捆绑软件而导致出现错误的可能性):
config(ssl_verifypeer = F, sslcert = "path to new cert.pem", sslkey = "path to new key.pem")
但是,每当我运行httr::POST
请求时,都会出现以下错误:
Error in curl::curl_fetch_memory(url, handle = handle) :
schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs
when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows
System event log.
我不知道我在这里犯了什么错误,但是我一直在努力解决它。这里的任何帮助将是救生员。
凯尔,
请查看以下答案:
How to specify certificate, key and root certificate with httr for certificate based authentication?
我的一般建议是首先使用curl
测试,验证您的请求是否有效,然后转换为httr
请求。
我希望以上内容为您指明正确的方向。