OpenSSL extracts pfx certificate key pairs

Source: Internet
Author: User
Tags openssl rsa pkcs12

When I was just working on the UnionPay project, the other party gave two test files: 1. pfx and 1. Cer. Summarize the two files to extract the text.

UnionPay provides two test certificates: 1.pfx and 1.cer.

The pfx certificate contains the RSA public key and key. the CER certificate is used to extract the key from the pfx certificate and allow the current computer to perform legal operations.

 

The extraction steps are as follows:

1. Click 1.certo install the CER certificate.

2. extract key information from pfx and convert it to the key format (pfx uses PKCS12 mode to supplement)

(1) extract key pairs

OpenSSL PKCS12-In 1.pfx-nocerts-nodes-out 1.key

// If the pfx certificate is encrypted, the system prompts you to enter the password. If the CER certificate is not installed, the password cannot be verified.

(2) extract the private key from the key pair

OpenSSL RSA-In 1.key-out primary pri.key

(3) extract the public key from the key pair

OpenSSL RSA-In 1.key-pubout-out cipher pub.key

(4) because the RSA algorithm uses the pkcs8 mode, further processing of the extracted private key is required.

OpenSSL pkcs8-topk8-inform PEM-in primary pri.key-outform PEM-nocrypt

Copy the key generated in the window and save it as your pri_pkcs8.key

(5) obtain the primary pri_pkcs8.key and primary pub.key of the key pair.

 

OpenSSL extracts pfx certificate key pairs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.