How to convert .P7B certificate to .PFX

WBOY
Release: 2023-05-13 21:04:04
forward
2834 people have browsed it

.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
Copy after login
  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
Copy after login
  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
Copy after login
  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
    Copy after login
Create a certificate request (CSR)

$ openssl req -new -newkey rsa:2048 -sha256 -nodes -out cert.csr \
-keyout cert.key
Copy after login

- 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
Copy after login

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!

source:yisu.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!