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

har*_*sha 4 r client-certificates rcurl httr

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

以下 curl 有效。

curl -H "userName:sriharsha@rpc.com" --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 的选项。

咖啡馆=????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),详细())

因此,我正在为 curl 的(--cert、--key 和--cacert)寻找 httr 的等效选项。

har*_*sha 7

基于curl 文档,选项为

  1. ssl 证书是sslcert
  2. ssl 密钥是sslkey
  3. ssl ca 是cainfo

根据以下命令工作

cafile="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 = 密钥文件))