Home > Backend Development > PHP Tutorial > Solution to garbled code in DER format certificate read by php, garbled code in DER format_PHP tutorial

Solution to garbled code in DER format certificate read by php, garbled code in DER format_PHP tutorial

WBOY
Release: 2016-07-13 09:49:02
Original
932 people have browsed it

Solution to garbled code in php reading der format certificate, garbled code in php reading der format

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:

 
<&#63;php
$cert = file_get_contents('filename.crt');
$ssl = openssl_x509_parse($cert);
var_dump($ssl);
&#63;>
Copy after login

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020543.htmlTechArticleSolution to garbled code in php reading der format certificate, problems encountered in php reading garbled der format: My project needs The public key of the certificate in der format and the RSA algorithm are used to verify the relevant signature. PHP is about...
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template