Home  >  Article  >  Operation and Maintenance  >  How to extract private key and certificate from .pfx file

How to extract private key and certificate from .pfx file

不言
不言Original
2019-03-15 11:14:4010528browse

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

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:

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!

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