Problems encountered:
My project needs to use the public key of the certificate in der format and the RSA algorithm to verify the relevant signatures. I don’t know much about the RSA algorithm in PHP. I have implementations in Java and .net languages. The PHP implementation is very useful. Hard work.
Answers from friends:
This certificate has its own corresponding encoding. You must first find this, then read it with php and set the corresponding encoding. In addition, if you directly echo the certificate content, it is best to encode it with the tag before that, otherwise it is not garbled, but your browser cannot recognize it. Also pay attention to the encoding of your php file~~
Of course, reading it directly will be garbled. The der key certificate is originally a binary-encoded or BASE64-encoded file. PHP can use the openssl_x509_parse function to parse:
<?php $cert = file_get_contents('filename.crt'); $ssl = openssl_x509_parse($cert); var_dump($ssl); ?>
The above is the entire content of this article, I hope you all like it.