LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2005, 06:44 AM   #1
chr15t0
Member
 
Registered: Jun 2002
Location: London
Distribution: Slackware
Posts: 201

Rep: Reputation: 30
stuck with php/curl and SSL certificates


right - I'm really stuck here.

I am using php/curl to talk to a remote system. I have been issued with a client certificate, which basically consists of a private key concatenated with a certificate. I slurp all this into $clientcert and specify it using

curl_setupt($ch, CURLOPT_SSLCERT, $clientcert);

I have also exported this certificate with the private key, converted it into a .pem file and pasted the private key section into a file called clientkey.key. I'm pointing curl at this using:

curl_setopt($ch, CURLOPT_SSLKEY, $clientkey);

where $clientkey contains the path to the clientkey.key file.

I also have the SSLCERTPASSWD specified, and it's definitely right

However I still get this error: 58 - unable to use client certificate (no key found or wrong pass phrase?).

I have this working just perfectly from the command line, so I really just want to translate this command into the php/curl equivalent:

Quote:
curl -E /export/newtos/frontend/etc/client-cert.pem:blabla --cacert /export/newtos/frontend/etc/northside.pem --data-binary @/root/temp/file-converted.txt -H "Content-Type: multipart/related; type="text/xml"; boundary="--someBoundaryValue--"; start="ebXML_Message_Header"" https://www.blabla.com/north
What am I doing wrong here? It could be that I'm missing out the '--cacert' option, which points to the northside.pem, which I think is a root certificate. I get horribly confused with all this stuff.. how do I specify this bundle using curl_setopt()?


Any thoughts would be great,



christo

Last edited by chr15t0; 05-12-2005 at 08:24 AM.
 
Old 05-13-2005, 05:13 AM   #2
chr15t0
Member
 
Registered: Jun 2002
Location: London
Distribution: Slackware
Posts: 201

Original Poster
Rep: Reputation: 30
I've finally managed to get the command to work - I realised that I was using the contents of the client certificate instead of a path to the client certificate... I'm not sure why I ended up doing that, but anyway...

so the code now looks like this and seems to work well:

PHP Code:
        $url            =       "https://www.bla.com/foo"// onramp url

        
$clientcert    =       $diagno_libdir."/exported-with-private-key.pem";
        
$keyfile        =       $diagno_libdir."/clientkey.key";
        
$challenge      =       "nightmare";

        print 
"<bR><BR>$challenge<br><br>";
        print 
"<bR><BR>$keyfile<br><br>";

        
$header = Array();
        
$header[] = "Content-Type: multipart/related \r\n";
        
$header[] = "type=text/xml \r\n";
        
$header[] = "boundary=--someBoundaryValue-- \r\n";
        
$header[] = "start=ebXML_Message_Header \r\n";
        
$header[] = $iptest;

        
$ch curl_init();

        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_HEADER1);
        
curl_setopt($chCURLOPT_VERBOSE1);
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_HTTPHEADER$header);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
        
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
        
curl_setopt($chCURLOPT_FAILONERROR1);
        
curl_setopt($chCURLOPT_SSLCERT$clientcert);
        
curl_setopt($chCURLOPT_SSLCERTPASSWD$challenge);
        
curl_setopt($chCURLOPT_SSLKEYTYPE'PEM');
        
curl_setopt($chCURLOPT_SSLKEY$keyfile);

        
$ret curl_exec($ch); 
hopefully somebody will discover this thread and find our comments useful


best wishes


christo
 
Old 05-20-2005, 06:10 AM   #3
vedad75019
LQ Newbie
 
Registered: May 2005
Posts: 1

Rep: Reputation: 0
Hi,

I'm a total SSL newbie, and i'm facing the same problem as you...

I have a password protected client certificate. So far, everything's okay.
But i don't have a clue about the "private key" concern.

Could you please explain what does:

Quote:
I have also exported this certificate with the private key, converted it into a .pem file and pasted the private key section into a file called clientkey.key. I'm pointing curl at this using:
mean?

Thanks!
Best regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssl and verisign trail certificates helpme0904 Fedora 0 06-09-2005 03:57 PM
SSL certificates the-chains Linux - Software 0 11-15-2004 07:12 PM
ssl certificates champ Linux - Security 2 04-05-2003 09:47 AM
ssl certificates Syncrm Linux - General 7 02-26-2003 10:01 AM
SSL Certificates and root authorities antken General 2 01-24-2003 10:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration