HTTPS-P7B Certificate Conversion

Source: Internet
Author: User
Tags pkcs7

Recently in the configuration of HTTPS work order, encountered two customer-provided CRT nonstandard, need to manually from the p7b file to Base64 encoding according to P7B and CRT files to export the certificate one by one, stitching into a new CRT, the process is more cumbersome. To improve efficiency, online queries have found a way to convert the CRT using commands, in the following steps:

Take the 1.A.COM.P7B certificate as an example and convert to 1.A.COM.CRT

    1. To run the fold command conversion format
      fold -w 64 1.a.com.p7b > temp.p7b
    2. Convert p7b to CRT using OpenSSL
      openssl pkcs7 -print_certs -in temp.p7b |grep -Ev ‘^\s*$|subject|issuer‘ > 1.a.com.crt

      corresponding script

#!/bin/bashp7b_file="$1"p7b_filename=$(echo ${p7b_file} |sed -r ‘s#(.*).p7b#\1#g‘)usage (){    echo "Usage:sh $0 p7b_file"    exit 0}[ $# -ne 1 ] && usagefold -w 64 ${p7b_file} > temp.p7bopenssl pkcs7 -print_certs -in temp.p7b |grep -Ev ‘^\s*$|subject|issuer‘ > ${p7b_filename}.crt

    • How to use
      sh p7b_to_crt.sh p7b文件

    • Actual Use Cases
      sh p7b_to_crt.sh owner1a_520wdy_com.p7b

The generated CRT is in the current directory with the same name as the p7b file.

HTTPS-P7B Certificate Conversion

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.