如何使用httr为基于证书的身份验证指定证书,密钥和根证书?
问题描述:
我想从服务器使用httr库访问数据,它需要基于证书的身份验证。我有证书(cert.pem),密钥文件(key.pem)和根证书(caroot.pem)如何使用httr为基于证书的身份验证指定证书,密钥和根证书?
继卷曲的作品。
卷曲-H “用户名:[email protected]” --cert cert.pem --key certkey.key --cacert caroot.pem https://api.somedomain.com/api/v1/timeseries/klog?limit=1
如何指定certkey.key和caroot.pem到httr GET请求。我正在尝试使用以下R命令,但无法找到指定证书密钥和caroot的选项。
凭证档案错误= ???? (config)(cainfo = cafile,ssl_verifypeer = FALSE),详细())
因此我要找的(--cert,--key和--cacert)卷曲HTTR的等效选项。
答
基于curl docs,选项
按即下面的命令工作
凭证档案错误= “ca.pem”
certFile中= “cert.pem”
密钥文件= “certkey.key”
ř< -GET( “https://api.somedomain.com/api/v1/timeseries/klog”,查询=列表(限制= 1),add_headers(“userName”=“[email protected]”),config(cainfo = cafile,sslcert = certfile,sslkey = keyfile))