I'll explain the situation.
Short version is that I have received a ssl certificate and I need to include it in some HTTP requests. And I haven't managed to correctly do it.
I'm using Guzzle to make the requests.
I have received the certificate as a string starting with
-----BEGIN CERTIFICATE-----
and ending with
-----END CERTIFICATE-----
.
First of all I'm not 100% sure, what do I have to do with it in order for it to be ready to be included in the request. I saved it as a mycert.crt
file. As the Guzzle docs mentioned they need a .pem file, I looked into converting .crt file to .pem file. Found this stackoverflow thread, tried them both and it didn't work (btw the .crt and .pem contents are identical). Let me explain, what did not work.
I made a
$client = new GuzzleHttp\Client(['base_uri' => 'https://theuri.com']);
$client->request('GET', 'getit', ['cert' => 'path/to/mycert.pem' ]);
The result was
[GuzzleHttp\Exception\ConnectException]
cURL error 35: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
I read that it's some standard error, when you've messed something up in the whole process of making a request with a certificate.
I also have private.key file and request.csr which were used in creating the SSL key. Not sure if I have to do anything with these now.
I have not found much helpful information online. The threads or articles that I have found have not explained the whole process from start to end so I haven't been confident in any of the methods I've tried.
EDIT:
I've found out that I should probably be using
$client->request('GET', '/getit', ['verify' => 'path/to/mycert.pem'])
It gives me the exception
GuzzleHttp\Exception\ConnectException with message 'cURL error 35: SSL peer handshake failed, the server most likely requires a client certificate to connect (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'
If I do it with 'cert', it's saying it can't load the certificate and its private key. I doubt that using 'cert' is the way to go.