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

curl-and-php

Faulty client certificate in PHP

From: Lucian Daia <wildus1_at_hotmail.com>
Date: Mon, 28 Feb 2011 00:22:30 +0000


Hello!
 
I've been trying for some time to connect to a Windows Azure account that requires a client certificate using PHP, but I keep getting SSL errno 10054, which basically means that the remote host rejected me. Here are some details I can provide:
 
1) The PHP Script I am using
 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, '1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: management.core.windows.net', 'x-ms-version: 2010-04-01'));
curl_setopt($ch, CURLOPT_SSLCERT, 'cert.pem');
curl_setopt($ch, CURLOPT_CRLF, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // just on development
 
2) The curl command line script I am using:
 
curl -k -E wazuremgm.pem --Verbose -H "x-ms-version: 2010-04-01" https://management.core.windows.net/<subscription-id>/90/services/hostedservices
 
The funny thing is that the command line version works, while the PHP counter-part doesn't. I've added Fiddler to the mix to see exactly why it doesn't work and it seems that although both scripts send *exactly* the same data, the PHP version simply hangs when it's time to send the client certificate and the remote host decides to cut the communications channel after a while.
 
Just in case it's necessary, here are the cURL details for my PHP installation:
- version 7.21.2
- OpenSSL version 0.9.8l
- Zlib 1.2.3
- libSSH 2/1.2.7
 
And for the command-line tool:
- version 7.21.4
- OpenSSL version 0.9.8r
- Zlib 1.2.5
- libSSH 2/1.2.7
 
My operation system is Windows Vista and PHP version is 5.3.3 / 5.3.5 (doesn't work on any of them). The certificate was converted correctly and it's a .pem with both the certificate and private key segments in the same file. It's obviously not a certificate problem, since the command-line version works just fine with it.
 
If I can provide you with any more details, I'd be glad to!
 
Thanks,
Lucian

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2011-02-28