library(openssl)
library(httr)
library(usethis)
# set up openssl in .Renviron
usethis::edit_r_environ() #opens .Renviron file in Rstudio
# include this line into .Renviron file:
CURL_SSL_BACKEND="openssl"
# read your pfx certificate
cert <- openssl::read_p12(file = ".../yourCertificate.pfx", password = "yourKey")
# convert pfx to cert and key pem files to use in httr calls
openssl::write_pem(cert$cert, "my_cert.pem")
openssl::write_pem(cert$key, "my_key.pem")
# send request
GET("https://...", config = config(sslcert = "my_cert.pem", sslkey = "my_key.pem"), verbose())
2条答案
按热度按时间tvmytwxo1#
我也遇到了同样的问题,我是这样解决的:
wj8zmpe12#
2023年4月,get方法返回错误:
这似乎与curl 7.55.1中引入的问题有关(参见https://stackoverflow.com/a/71496170/5956120)在curl 8.0.1中使用证书再次工作。
解决方法可以在R中实现: