2

Is it possible to create a POST request using guzzle6 which has .pfx-certificate attached to it?

The documention only mentions pem-format: http://docs.guzzlephp.org/en/stable/request-options.html#cert

jjei
  • 1,050
  • 3
  • 12
  • 19
  • 1
    Just convert the [`.pfx` file to `.pem`](https://stackoverflow.com/questions/15413646/converting-pfx-to-pem-using-openssl). – Alexey Shokov Dec 05 '17 at 18:41
  • I tried this but using pem format didn't work out in my context. Apparently there are some problems with mac os x and pem certificate https://stackoverflow.com/questions/40712352/curl-error-58-ssl-cant-load-the-certificate-and-its-private-key-osstat – jjei Dec 14 '17 at 08:48

2 Answers2

2

Although the documentation at http://docs.guzzlephp.org/en/stable/request-options.html#cert doesn't mention it, it seems to be possible to also use pfx-format with guzzle.

jjei
  • 1,050
  • 3
  • 12
  • 19
0

PFX certificates are used for "mutual authentications", that means, the PFX is generated with your local private key and the remote public cert.

To generate a PFX key you run:

openssl pkcs12 -inkey your_privkey.pem -in remote_pub.cert -export -out mixed.pfx

To make a request using the PFX cert, you can:

$api = new \GuzzleHttp\Client([
    'base_uri' => $baseUrl,
    'cert'     => 'path/to/mixed.pfx',
    'curl'     => [CURLOPT_SSLCERTTYPE => 'P12'], // to define it's a PFX key
]);
StR
  • 524
  • 6
  • 17