【问题标题】:How to specify certificate, key and root certificate with httr for certificate based authentication?如何使用 httr 指定证书、密钥和根证书以进行基于证书的身份验证?
【发布时间】:2016-05-17 10:41:23
【问题描述】:

我正在尝试使用来自服务器的 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 的选项。

cafile=???? rhttps://api.somedomain.com/api/v1/timeseries/klog", query = list(limit = 1), add_headers("userName"= "sriharsha@rpc.com"), config(cainfo = cafile, ssl_verifypeer=FALSE), verbose())

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

【问题讨论】:

    标签: r client-certificates rcurl httr


    【解决方案1】:

    基于curl docs,可选

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

    按照下面的命令工作

    cafile="ca.pem"

    certfile="cert.pem"

    keyfile="certkey.key"

    rhttps://api.somedomain.com/api/v1/timeseries/klog", query = list(limit = 1), add_headers("userName"= "sriharsha@rpc.com"), config(cainfo = cafile, sslcert = certfile, sslkey =密钥文件))

    【讨论】:

    • 特别是命令行选项--cacert对应配置选项cainfo
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 2023-03-29
    • 2021-06-21
    • 2016-10-02
    • 2020-09-22
    • 2018-02-24
    • 2021-04-05
    相关资源
    最近更新 更多