如何为基于证书的身份验证使用httr指定证书,密钥和根证书? [英] How to specify certificate, key and root certificate with httr for certificate based authentication?

查看:93
本文介绍了如何为基于证书的身份验证使用httr指定证书,密钥和根证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to access data using httr library from server which expects certificate based authentication. I have certificate (cert.pem), key file (key.pem) and root certificate (caroot.pem)

遵循curl的工作原理。

Following curl works.


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

如何为httr GET请求指定certkey.key和caroot.pem。我正在尝试使用R命令,但是找不到指定证书密钥和caroot的选项。

How can specify certkey.key and caroot.pem to httr GET request. I am trying with following R command but couldn't find option to specify cert key and caroot.


cafile = ????
r< -GET( https://api.somedomain.com/api / v1 / timeseries / klog ,查询=列表(限制= 1),add_headers( userName = sriharsha@rpc.com),配置(cainfo = cafile,ssl_verifypeer = FALSE),verbose() )

cafile=???? 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), verbose())

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

Thus I am looking for equivalent options of httr for (--cert, --key and --cacert) of curl.

推荐答案

基于 curl文档


  1. ssl证书的选项为 sslcert

  2. ssl密钥是 sslkey

  3. ssl ca是 cainfo

  1. ssl certificate is sslcert
  2. ssl key is sslkey
  3. ssl ca is cainfo

按照以下命令的操作d

As per that following command worked


cafile = ca.pem

cafile="ca.pem"

certfile = cert。 pem

certfile="cert.pem"

keyfile = certkey.key

keyfile="certkey.key"

r< -GET( https://api.somedomain.com/api/v1/timeseries/klog ,查询=列表(限制= 1),add_headers( userName = sriharsha@rpc.com),config(cainfo = cafile,sslcert = certfile,sslkey = keyfile))

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))

这篇关于如何为基于证书的身份验证使用httr指定证书,密钥和根证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆