最近对接了一个来自于深圳***的JAVA接口、他们给了一个p12 的证书,貌似对PHP来说不达标,需要将该证转换为PEM格式。
使用Linux命令直接转换:
openssl pkcs12 -clcerts -nokeys -out cbip0151.pem -in cbip0151.p12
或
openssl pkcs12 -in cbip0151.p12 -out cbip0151.pem -nodes
转换后获得的pem 证书内容是:(用Notepad++打开 缺陷显示)
Bag Attributes
friendlyName: cbip0151
localKeyID: 1F 51 54 7F 17 F3 06 1B 88 CB 14 4D D5 4A 78 CD B7 46 C7 20
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDZsIpDpPuaskSP
nk8B4i+6nAFvWJ7Qoxqnqm2peDxxctE31fe+TeJdfQcj
NMrnU/fx7SzC2p7e8WbycElnRK+/8gvNtp8RMGwfMf4KOypXJ+3Ze2Z3Bvn26zH2
VGOStB6Tcm1rBxusud6/QU2zHrOOY0BsycxGDylD+Rb6T72z+MtLZ1oiSPubXG4O
BronioSg1lGFEptIK5CCc8EWPn81aIzOt5EnnQ7Vo5PFQ1er/9mDRz1BxrjIIaSA
iqVFo2VMPp4VRDCnlCr7nJraKGhggV8w4mDbKxkCHeLGkSjPknTyk
9ahBwLWtAgMBAAECggEAAIkd6fkxskl+gDD2Rk2paubf3QeFioNgORlNh96GsMB0
eQA3bT+Xy58AepKEaY4MBDxnSeVUqYC5gAVs+2E6QrLf8ZHKosdKxs1ubM3fNdRx
YX3xyb/KAFCl7J4FJmY/gFG8qI3QlyIwgwfln9KIIbo+GS2RDJ1/dg6B068/Z1oH
gOCwgGLoJsIZM5Y87xCKVRQCHHfp3MtMRFJP16XGTbT8E+LJi1g/OOCk2+hFYXlo
xFiNM9irmGFAs8ArjpTZ+tz3o9JlrPG+GeNcfmtRXfb5qydTkamKTA7KQp46uaWd
A8THxC4LO4o4mQNuTVRTwXhDM/t0iCFtycIcPnvzSQKBgQDvibQRLCHL7a8ZglIQ
uR0gQnEMyW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