I'm trying to send a SOAP request to receive some data with R and httr
, but receive something i cannot interpret and fix.
I have a web certificate in a .p12 file, and a password for it (in text).
I tried 2 approaches:
library(httr)
url <- 'https://www.b2b.preops.nm.eurocontrol.int/B2B_PREOPS/gateway/spec/26.0.0'
payload <- '<item:itemName>
<userId>myUserID</endUserId>
<sendTime>2023-03-28 11:42:28</sendTime>
<data>
<type>NEW</type>
</data>
</item:itemName>'
keystore <- "my_p12_file.p12"
keystore_password <- "the_password"
headers <- list(`Content-type`="application/soap+xml;charset=UTF-8", SOAPAction = "Get")
response <- POST(url,
body = payload,
add_headers(headers),
config = list(
sslcert = keystore,
sslkey = keystore_password
),
verbose(
data_out = F,
data_in = F,
info = T,
ssl = F)
)
Here i received this note:
* Uses proxy env variable https_proxy == 'http://my_proxy_details:port'
* Hostname in DNS cache was stale, zapped
* Trying HIDDEN...
* Connected to HIDDEN (#5)
* allocate connect buffer
* Establish HTTP proxy tunnel to HIDDEN_LINK
-> CONNECT HIDDEN_LINK HTTP/1.1
-> Host: HIDDEN
-> User-Agent: libcurl/7.84.0 r-curl/5.0.0 httr/1.4.5
-> Proxy-Connection: Keep-Alive
->
<- HTTP/1.1 200 Connection established
<-
* Proxy replied 200 to CONNECT request
* CONNECT phase completed
-> POST /LINK_HTTP
-> Host: HIDDEN_HOST
-> User-Agent: libcurl/7.84.0 r-curl/5.0.0 httr/1.4.5
-> Accept-Encoding: deflate, gzip
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Length: 897
->
* Mark bundle as not supporting multiuse
<- HTTP/1.1 200 OK
<- connection: close
<- content-length: 36
<- content-type: application/json
<- date: Wed, 29 Mar 2023 19:17:37 GMT
<- p3p: CP="NON CUR OTPi OUR NOR UNI"
<- expect-ct: max-age=86400,enforce
<- permissions-policy: accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=()
<- x-frame-options: SAMEORIGIN
<- x-content-type-options: nosniff
<- cache-control: no-store
<- x-xss-protection: 1
<- content-security-policy: default-src 'none'; base-uri 'self'; upgrade-insecure-requests; block-all-mixed-content; frame-ancestors 'self'; form-action 'self'
<- referrer-policy: strict-origin-when-cross-origin
<- strict-transport-security: max-age=63072000; includeSubDomains; preload
<- feature-policy: accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'
<- pragma: no-cache
<-
* Closing connection 5
* schannel: shutting down SSL/TLS connection with HIDDEN PORT HIDDEN
Then I typed in:
response
and I received
Response https_link_hidden
Date: 2023-03-29 19:17
Status: 200
Content-Type: application/json
Size: 36 B
{
"operation" : "failed_cert"
}
as proposed I tried to read the p12 file using this solution
library(openssl)
ps_key <- openssl::read_p12(keystore, keystore_password)
and then run the modified code:
response <- POST(url,
body = payload,
#add_headers(headers),
config = list(
sslcert = ps_key$cert,
sslkey = ps_key$key
),
verbose(
data_out = F,
data_in = F,
info = T,
ssl = F)
)
I get this strange binary error H��Jq7�0
any help/opinion is appreciated