ASN1 header when doing public key pinning on iOS Swift

301 views Asked by At

In most of the examples I can find from google, I always see people hard-coded some ASN1 header like this:

let rsa2048Asn1Header:[UInt8] = [
   0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
   0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00
]

However, if I try to grab the google cert with

openssl s_client connect www.google.com:443 < /dev/null | openssl x509 -outform DER > google.der

and use

openssl asn1parse -inform DER -in google.der -noout -out data && hexdump -C data

The header is obviously not the same. I am not very familiar with SSL and my questions are;

1, How do you get the value of the RSA2048 ASN1 header?

2, Should I always just use the rsa2048 ASN1 header, or should I extract asn1 header everytime when I try to cert-pin a host?

0

There are 0 answers