user4817873
user4817873

Reputation:

Get private key .pfx in PHP

How to I extract private key/public key in digital signature .pfx format using PHP?

I want to encrypt data with my private key .pfx but I got an error when I open it using .pfx format. Another question: is it possible to extract the keys with .pfx format? or should I use the .pem format? Or is it possible to encrypt the data using .pfx format?

Upvotes: 5

Views: 7693

Answers (1)

laurent
laurent

Reputation: 90776

PHP has a function to read this certificate:

$data = file_get_contents('/path/to/cert.pfx');
$certPassword = 'your password';
openssl_pkcs12_read($data, $certs, $certPassword);
var_dump($certs);

But to encrypt data with this certificate, you'll need the other PHP openssl functions.

Upvotes: 11

Related Questions