以1.a.com.p7b证书为例,转换为1.a.com.crt
- 运行fold命令转换格式
fold -w 64 1.a.com.p7b > temp.p7b
- 使用OPENSSL将p7b转换为crt
openssl pkcs7 -print_certs -in temp.p7b |grep -Ev ‘^\s*$|subject|issuer‘ > 1.a.com.crt
对应脚本
#!/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
- 使用方法
sh p7b_to_crt.sh p7b文件
- 实际用例
sh p7b_to_crt.sh owner1a_520wdy_com.p7b
生成的crt在当前目录下,与p7b文件同名。
HTTPS-p7b证书转换
原文地址:http://blog.51cto.com/xoyabc/2058746