I'm trying to get php to report the public key length of a certificate as a representation of bits.
e.g. 1024, 2048, 4096 etc.
I've trawled though countless functions on the PHP docs for answers or a steer in the right direction. Cant for the life of me work out a function that will provide this data.
http://php.net/manual/en/ref.openssl.php
openssl_pkey_get_details() seemed like the way to go. But cant find a way to give it the public key in the first place.
Currently i can parse the certificate. However this doesn't include the public key or bits information.
<?php
$cert = $_POST['cert_text'];
$ssl = openssl_x509_parse($cert);
echo json_encode($ssl);
?>
The $cert variable above is a PEM format certificate file. So in the format of
-----BEGIN CERTIFICATE-----
MIIGWTCCBUGgAwIBAgIKG6SqTwACAAAANzANBgkqhkiG.....etc..
-----END CERTIFICATE-----