Home > Article > Operation and Maintenance > How to convert .P7B certificate to .PFX
1. Download the openssl tool, (here we take the windows system as an example)
https://www. chinassl.net/download/d1.html
2. Format conversion
a A P7B file is a text file that contains the certificate and certificate chain, but not the private key.
Specifies a portable format for storing and transmitting user or server private keys, public keys, and certificates. It is a binary format and these files are also called PFX files.
It should be noted that in order to do the conversion, you must have the certificate cert.p7b file and the private key cert.key file.
$ openssl pkcs7 -print_certs -in cert.p7b -out cert.cer
-print_certs: Output any certificates contained in the file.
-in: Specify the input file.
-out: Specify the output file.
$ openssl pkcs12 -export -in cert.cer -inkey cert.key -out cert.pfx
-export: Indicates exporting the certificate.
-in:Specifies the file name of PKCS#12.
-inkey: Specify the private key file name.
-out: Specify the output file.
3. Extension:
Create a 2048-bit RSA certificate, valid for 5 years:
$ openssl req -new -x509 -days 1825 -sha256 -nodes -out cert.crt \ -keyout cert.key
req: Generate certificate issuance request command
-new: Indicates a new request.
-x509: Command to issue X.509 format certificate.
##-days: means Validity days.
-sha256: represents the certificate digest algorithm, here is SHA256.
-nodes : The private key will not be encrypted.
-out: Specify the output file name.
-keyout: Specify the file name of the newly created private key.
$ openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.pfx
$ openssl req -new -newkey rsa:2048 -sha256 -nodes -out cert.csr \ -keyout cert.key
- newkey: Create a new certificate request and KEY.
Note: "Country Name" must be "CN", other fields can be filled in as you like. Create RSA private key for PFX$ openssl pkcs12 -in cert.pfx -nocerts -nodes | openssl rsa -out rsaprivkey.pem
The above is the detailed content of How to convert .P7B certificate to .PFX. For more information, please follow other related articles on the PHP Chinese website!