Search code examples
phpsecuritysslx509serial-number

PHP SSL Certificate Serial Number in hexadecimal


I need to display SSL certificat information about Serial Number. When I use

$cert = file_get_contents('mycert.crt');
$data=openssl_x509_parse($cert,true);
$data['serialNumber']

I receive like -5573199485241205751 But when I run command openssl x509 -in 'mycert.crt' -noout -serial I receive serial=B2A80498A3CEDC09 is it possible receive in PHP? Thanks.


Solution

  • Thanks Petey B the idea was interesting so have help me to find direction to search. The solution is:

    $serial_number= strtoupper(dechex($serial_number));