Home > Backend Development > PHP Tutorial > Solution to garbled code in DER format certificate read by PHP_PHP Tutorial

Solution to garbled code in DER format certificate read by PHP_PHP Tutorial

WBOY
Release: 2016-07-13 09:49:15
Original
1222 people have browsed it

Solution to the garbled code of the DER format certificate read by php

This article mainly introduces the relevant information on the garbled solution of the der format certificate read by php. Friends who need it can refer to it

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. PHP does not know much about the RSA algorithm. I have implementations in Java and .net languages. The PHP implementation is very useful. Hard work.

Friends’ answers:

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 tags 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:

 ?

1

2

3

4

5

6

 

$cert = file_get_contents('filename.crt');

$ssl = openssl_x509_parse($cert);

var_dump($ssl);

?>

1

2 3

45 6
$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. http://www.bkjia.com/PHPjc/1020276.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020276.htmlTechArticlephp reads the der format certificate garbled solution This article mainly introduces the php read der format certificate garbled solution For relevant information, friends who need it can refer to the problems encountered below: My...
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