0

There is a new certificate in pem format. How to get from it (using openssl?) a format expeced by ios? (example: https://github.com/Alamofire/Alamofire/blob/master/Source/ServerTrustPolicy.swift) I've tried using something like:

openssl x509 -in newcertificate.crt -outform der |openssl dgst -sha256 -binary |openssl enc -base64

But it doesn't generate output like debug in ios library. I can of course get pinning from debug in library - but i would like to receive the same pinning using openssl command.

  • Have you tried just renaming its extension to crt? (pem is very generic and doesn't tell you if it contains a key, a certificate, both or whatever. Beyond that, there's mostly ascii-armored and binary formats, but hopefully, the unterlying library will handle both.) – Ulrich Schwarz Apr 9 '18 at 10:11
  • in openssl there is option: -outform arg - output format - default PEM (one of DER, NET or PEM) - so i've used openssl terminology :-) – undefine Apr 9 '18 at 11:50
0

If you're planning to have iOS load the certificate from a web page, you'll just need to ensure the web server provides the correct MIME type for it. For a pem formatted certificate, the MIME type is application/x-x509-ca-cert. If the MIME type is correct, iOS can accept a PEM-formatted certificate as-is, present some "are you sure to accept..." prompts and install it as a minimal "configuration profile" with just the certificate in it.

If you need to feed iOS both the certificate and the corresponding private key (i.e. you'd need the certificate not for verifying the identity of some service, but to actually use the certificate for authenticating into something), then you might want to package both the certificate and the key into a single PKCS#12 file (suffix .pfx or .p12), and serve it up as MIME type application/x-pkcs12. The conversion to PKCS#12 format can be done with the openssl pkcs12 -export command: see man pkcs12 for details.

Another option would be to wrap the certificate into an Apple-style "configuration profile" with a .mobileconfig suffix (and the corresponding MIME type application/x-apple-aspen-config). However, creating a .mobileconfig file is tricky unless you have some tool that can do it for you. The.mobileconfig file is an Apple plist, i.e. a XML file with a specific structure, and it can optionally be signed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.