r-添加P12证书获取电话
我在Postman中成功打电话,在那里我访问了带有.p12证书的API。在Postman中,证书存储在全球设置中。
现在,我试图将此邮递员转换为R-Code,在那里我花了几个小时使用httr
和rcurl
软件包。不幸的是,如果没有结果,我的呼叫结果为403(没有有效的证书)。
我的步骤:
首先,我为呼叫定义了标题,
headers = c(
'Content-Type' = 'application/pdf',
'Authorization' = 'Basic ...'
)
#Set URL
url = "https://myurlwithcertificate.eu"
下一步我链接到.p12证书
#Cert info
pkcs12_name <- "certi.p12"
pkcs12_pwd <- "certificatePassword"
我尝试执行呼叫:
res <- httr::GET(url = url,
add_headers(headers),
config = config(sslcert=pkcs12_name,
sslkey=pkcs12_pwd))
引导:无法加载PEM客户端证书< /代码>
接下来,我还尝试首先使用read_p12
函数打开证书。
#Open certificate
cert <- read_p12(pkcs12_name,pkcs12_pwd)
我成功地打开了.p12证书。但是,我没有设法将证书和钥匙添加到API中。
res <- httr::GET(url = url,
add_headers(headers),
config = config(sslcert=cert$cert,
sslkey=cert$key))
作为测试,我在Python成功创建了这个电话。但是,我也想在R. python脚本中实现结果
:
import requests
from requests_pkcs12 import get
url = "https://myurlwithcertificate.eu"
payload={}
headers = {
'Content-Type': 'application/pdf',
'Authorization': 'Basic ...'
}
response = get(url, headers = headers, data=payload, pkcs12_filename='certi.p12', pkcs12_password='certificatePassword')
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
我感觉以某种方式在我的R-Script中我没有成功地在呼叫,URL和标题中添加证书很好。如果您有任何想法,我可以在电话中设法添加.p12证书,请让我知道:)
I have a successful call in Postman where I access an API with a .p12 certificate. In Postman, the certificate is stored in the global settings.
Now I am trying to translate this Postman-call to R-code, where I spent hours playing around using the httr
and rCURL
packages. Unfortunately, without results where my call results in a 403 (no valid certificate).
My steps:
First, I defined my headers for my call and the url
headers = c(
'Content-Type' = 'application/pdf',
'Authorization' = 'Basic ...'
)
#Set URL
url = "https://myurlwithcertificate.eu"
Next I linked to my .p12 certificate
#Cert info
pkcs12_name <- "certi.p12"
pkcs12_pwd <- "certificatePassword"
I tried to perform the call:
res <- httr::GET(url = url,
add_headers(headers),
config = config(sslcert=pkcs12_name,
sslkey=pkcs12_pwd))
Leading into: could not load PEM client certificate
Next I also tried to first use the read_p12
function to open the certificate.
#Open certificate
cert <- read_p12(pkcs12_name,pkcs12_pwd)
I managed to successfully open the .p12 certificate. However, I didn't manage to add the certificate and the key in my call to the API.
res <- httr::GET(url = url,
add_headers(headers),
config = config(sslcert=cert$cert,
sslkey=cert$key))
As a test, I have this call successfully created in Python. However, I also want to achieve the result in R.
Python script:
import requests
from requests_pkcs12 import get
url = "https://myurlwithcertificate.eu"
payload={}
headers = {
'Content-Type': 'application/pdf',
'Authorization': 'Basic ...'
}
response = get(url, headers = headers, data=payload, pkcs12_filename='certi.p12', pkcs12_password='certificatePassword')
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
I have the feeling that somehow in my R-script I didn't successfully managed to add the certificate in the call, url and headers are fine. Please if you have any ideas how I can manage to add the .p12 certificate in my call, let me know :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论