I'm writing a betting bot in PHP and the bet house requires a SSL Certificate being sent for automated connections.
I've got all kinds of self-signed certificates to use: cert.crt, cert.pem, cert.p12 and also a key cert.key and I'm using curl to establish the login connection however I can't seem to get the curl parameters right for the connection.
With the following command line I can establish a successful connection:
curl -q -k --cert cert.crt --key cert.key https://api.domain.com/certificatelogin/endpoint -d "username=UUUUUUU&password=XXXXXXX" -H "X-Application: appKey"
And this one works too:
curl -q -k --cert cert.pem https://api.domain.com/certificatelogin/endpoint -d "username=UUUUUUU&password=XXXXXXX" -H "X-Application: appKey"
The PHP code I'm currently using is as follows:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.domain.com/certificatelogin/endpoint");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Application: ' . $appKey,
'Accept: */*',
'Content-Type: application/x-www-form-urlencoded'
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSLCERT, "path/to/cert/cert.pem");
$postData = 'username=UUUUUUUUU&password=XXXXXXXXXXX';
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$response = json_decode(curl_exec($ch));
echo 'Response: ' . json_encode($response);
And after trying so many combinations with .crt and .key can't seem to make anything work at all.
Any help would be greatly appreciated. :)