Search code examples
phpsslauthenticationphp-opensslp12

Get information from p12 certificate file using PHP


My webpage has a login form that requests a p12 file to validate your identity using a certificate.

How can I get the p12 information using PHP code?


Solution

  • I think this will help you.

    $certs = array();
    $pkcs12 = file_get_contents( "pkcs12file.pem" );
    openssl_pkcs12_read( $pkcs12, $certs, "" );
    print_r( $certs );
    

    There are more in the documentation : PHP.net doc