cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Error code 58: unable to set private key file?

From: Dan Brown <danb_at_zu.com>
Date: Wed, 7 Jan 2009 14:18:05 -0600

I am attempting to use curl within PHP to connect to a site which requires
HTTPS client authentication (over IPSec!). I have been provided with the
public (x509/PEM) keys for their server but I am apparently doing something
wrong in my connection attempts.

I keep getting the following in my connection tests:

* About to connect() to 199.4X.14X.12X port 443
* Trying 199.43.146.123... * connected
* Connected to 199.4X.14X.12X (199.4X.14X.12X) port 443
* unable to set private key file: '/opt/bin/site-dev.crt' type PEM

* Closing connection #0
FATAL ERROR
On attempt the following error occured:
The return code was: 58

Once connected we'll be able to send SOAP requests for various information.

My code looks like this:

$ch = curl_init();

$url = "https://199.4X.14X.12X/";

// connection 1

// set url to use
curl_setopt($ch, CURLOPT_URL, $url);

// setup other curl options needed
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CAINFO,
'/usr/local/apache/conf/ssl.crt/ca-bundle.crt');
curl_setopt($ch, CURLOPT_SSLCERT, getcwd() .'/site-dev.crt');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
}
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$content = curl_exec($ch);
$error = curl_errno($ch);

if ($error > 0)
  print "Error: $error\n";
else
  print "Success!\n";

I do realize of course it is asking for a private key, so is there a way to
get it to use the public key instead?

____________________________________________________________________
Dan Brown
danb_at_zu.com

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-01-07