I'm trying to fetch a JSON array from my server using the HTTP POST method in R.
I've tried using both the POST
function from httr
and the getURL
function from RCurl
but both return errors.
cafile <- system.file("CurlSSL", "cacert.pem", package = "RCurl")
url <- "https://example.com/query/getData.php"
POST(url,body=NULL)
POST(url,body=NULL,config(cainfo=cafile))
getURL(url)
getURL(url,cainfo=cafile)
The error given by the POST
function is (for both calls):
Error in curl::curl_fetch_memory(url, handle = handle) :
SSL peer certificate or SSH remote key was not OK
The error given by the getURL
function is (without config(cainfo=cafile)
):
* Hostname was NOT found in DNS cache
* Trying 162.xxx.xxx.xxx...
* connect to 162.xxx.xxx.xxx port 443 failed: Connection refused
* Trying 130.yyy.yyy.yyy...
* Connected to example.com (130.yyy.yyy.yyy) port 443 (#0)
* found 175 certificates in /etc/ssl/certs/ca-certificates.crt
* gnutls_handshake() warning: The server name sent was not recognized
* failed to get server cert
* Closing connection 0
Error in function (type, msg, asError = TRUE) :
gnutls_handshake() warning: The server name sent was not recognized
I'm suspecting this has something to do with R since running:
curl 'https://example.com/query/getData.php'
from the command line return the expected result.
The server is a apache2 server with COMODO SSL certificate.
In /etc/apache2/sites-enabled/000-default.conf
the server name is set to
ServerName www.example.com
Any help would be most apreciated