如何使用httr为基于证书的身份验证指定证书,密钥和根证书?

时间:2016-05-17 10:41:24

标签: r client-certificates rcurl httr

我正在尝试使用来自服务器的httr库来访问数据,该服务器需要基于证书的身份验证。我有证书(cert.pem),密钥文件(key.pem)和根证书(caroot.pem)

以下卷曲工作。

  

curl -H“userName:sriharsha@rpc.com”--cece 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命令,但找不到指定cert key和caroot的选项。

  

凭证档案错误= ????   r< -GET(“https://api.somedomain.com/api/v1/timeseries/klog”,query = list(limit = 1),add_headers(“userName”=“sriharsha@rpc.com”),config(cainfo = cafile,ssl_verifypeer = FALSE),详细( ))

因此,我正在为卷曲的(--cert, - key和--cacert)寻找httr的等价选项。

1 个答案:

答案 0 :(得分:3)

基于curl docs

的选项
  1. ssl证书是sslcert
  2. ssl键是sslkey
  3. ssl ca是cainfo
  4. 按照以下命令工作

      

    凭证档案错误= “ca.pem”

         

    certFile中= “cert.pem”

         

    密钥文件= “certkey.key”

         

    r< -GET(“https://api.somedomain.com/api/v1/timeseries/klog”,query = list(limit = 1),add_headers(“userName”=“sriharsha@rpc.com”),config(cainfo = cafile,sslcert = certfile, sslkey = keyfile))