Home  >  Article  >  Operation and Maintenance  >  How to convert .P7B certificate to .PFX

How to convert .P7B certificate to .PFX

WBOY
WBOYforward
2023-05-13 21:04:042864browse

.P7B Convert 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

P7B (PKCS#7)

a A P7B file is a text file that contains the certificate and certificate chain, but not the private key.

PFX (PKCS#12)

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.

Convert P7B to PFX

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
  1. -print_certs: Output any certificates contained in the file.

  2. -in: Specify the input file.

  3. -out: Specify the output file.

$ openssl pkcs12 -export -in cert.cer -inkey cert.key -out cert.pfx
  1. -export: Indicates exporting the certificate.

  2. -in:Specifies the file name of PKCS#12.

  3. -inkey: Specify the private key file name.

  4. -out: Specify the output file.

3. Extension:

Create a self-signed certificate

Create a 2048-bit RSA certificate, valid for 5 years:

$ openssl req -new -x509 -days 1825 -sha256 -nodes -out cert.crt \
-keyout cert.key
  1. req: Generate certificate issuance request command

  2. -new: Indicates a new request.

  3. -x509: Command to issue X.509 format certificate.

  4. ##-days: means Validity days.

  5. -sha256: represents the certificate digest algorithm, here is SHA256.

  6. -nodes : The private key will not be encrypted.

  7. -out: Specify the output file name.

  8. -keyout: Specify the file name of the newly created private key.

  9. $ openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.pfx
Create a certificate request (CSR)

$ 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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete