How to make a valid p12 file to be correctly imported by SecPKCS12Import

不打扰是莪最后的温柔 提交于 2019-11-30 08:51:38
Hubert Wang

I got some tips from the internet, and following is the steps to get iOS acceptable p12 key and certification file:

  1. convert XML to PEM
    Shell> compile XMLSpec2PEM.java
    Shell> XMLSpec2PEM rsa.xml
    save the output result to rsa.pem
    (borrow from here)

  2. convert PEM to RSA Private Key
    OpenSSL> rsa -in rsa.pem -out rsaPrivate.key

  3. Generate a certification request
    OpenSSL> req -new -key rsaPrivate.key -out rsaCertReq.crt
    (input some basic certification data)

  4. Sign certification of the request
    OpenSSL> x509 -req -days 3650 -in rsaCertReq.crt -signkey rsaPrivate.key -out rsaCert.crt

  5. Convert the certification file format to DER (iOS acceptable format)
    OpenSSL> x509 -outform der -in rsaCert.crt -out rsaCert.der

  6. Generate PKCS12 Private key(iOS acceptable format)
    OpenSSL> pkcs12 -export -out rsaPrivate.pfx -inkey rsaPrivate.key -in rsaCert.crt

No further steps, files generated in step 5 and 6 now can be used in iOS!

reference of OpenSSL instructions:
http://blogs.yaclife.com/?tag=ios%E3%80%80seckeyref%E3%80%80raw%E3%80%80key%E3%80%80rsa%E3%80%803des

http://devsec.org/info/ssl-cert.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!