How to extract private key and certificate from .pfx file

不言
Release: 2019-03-15 11:14:40
Original
10564 people have browsed it

.PFX (Personal Information Exchange) files are used to store certificates, private keys, and public keys. For example, if we need to transfer an SSL certificate from one Windows server to another, we can export it as a .pfx file using the IIS SSL Export Wizard or the MMC console.

How to extract private key and certificate from .pfx file

Sometimes we need to extract the private key and certificate from the .pfx file, but we cannot execute it directly, so this article will introduce to you how to achieve it. We will also cover methods for migrating SSL certificates to AWS ELB, as ELB requires separate private keys and certificates.

Note: OpenSSL must be installed on a Windows or Linux system to use the following commands

Extract the private key from PFX

The following commands will extract the private key from the . Extract the private key from the pfx file. A new file private-key.pem will be created in the current directory. This command requires a password to be set on the pfx file.

$ openssl pkcs12 -in myfile.pfx -nocerts -out private-key.pem -nodes
Enter Import Password:
Copy after login

Extract certificate from pfx

Then extract the certificate file. The following command will extract the certificate from the .pfx file. The certificate can be found in a file called certificate.crt.

$ openssl pkcs12 -in myfile.pfx -nokeys -out certificate.crt
Enter Import Password:
Copy after login

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of How to extract private key and certificate from .pfx file. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
pfx
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