Hi, I am trying to connect to a secure server via CURL functions. I have PHP 4.3.1 in ISS 5.0, with the OpenSSL installed and working. However, when I try to access a given server via HTTPS (and with Certificates activated), it gives an error that it need Authentication.
The code is this, I tried in another local server also with a demo certificate from VeriSign activated, and works fine, I am desperate that I cannot connect to this other machine, and don't know if it is a problem of permissions or whatever. Any help will be extremely well welcomed!!!!...
CODE:
(<> means variable content depending on specific situations.)
$document = <XML-formatted string>
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, 'https://<domain>:442/servlet/PDSLRsT.dyn'); // address and port 442
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// headers
$method = "post";
$path = "/servlet/PDSLRsT.dyn'";
$host = "<domain>";
$header[] = "$method $path HTTP/1.1";
$header[] = "Host: $host";
$header[] = "Authorization: basic <base64 encoded string>";
$header[] = "Content-type: text/xml";
$header[] = "Mime-Type: text/BDU";
$header[] = "Content-length: " . strlen($document);
$header[] = "User-Agent: MSIE";
/// END HEADER
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $document);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;