search
Homephp教程php手册php读取der格式证书乱码解决方法,php读取der乱码

php读取der格式证书乱码解决方法,php读取der乱码

遇到的问题:

我的项目需要用到应用der格式的证书公钥及RSA算法来验签相关签名,PHP关于RSA算法不是很懂,手头上有Java和.net两种语言的实现,PHP实现甚感吃力。

小伙伴们的解答:

这个证书有他自己相应的编码,首先要找到这个,然后在用php读,设置对应的编码就好了。另外你如果是直接echo出证书内容的话,在那之前最好用标签编码一下,否则他其实没乱码,只是你浏览器无法识别而已。还要注意你php那个文件的编码哦~~

直接读取当然是乱码了,der密钥证书本来就是二进制编码或者BASE64编码的文件,php可以用openssl_x509_parse函数来解析:

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

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software