Parse Only user's certificate from certificate sequence.

I have got below string by parsing a p7b string to get certificate chain. I want to parse only user certificate from this in swift. How can i know what is my user's certificate? Actually I need to parse only my certificate. I have gone through the decoding file and found that there is 2 commonName SEQUENCE named by my name MUHAMMAD AHAD UL ALAM.

I have attached a file having the ASN1 informations after decoding.

Replies

Presumably this is on iOS. If it’s macOS, the answer is different.

That looks like CMS signed data. iOS has no CMS API. You’ll have to write, or acquire, a library to parse this data and extract the bits you need.

If you decide to write it yourself, give yourself a boost by starting with the SwiftASN1 project.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"