I'm trying to pin a public key. I have a SecKeyRef
, and I want to serialize it with SecRSAPublicKeyCopyPublicSerialization
. SecRSAPublicKeyCopyPublicSerialization
will serialize in PKCS#1 (i.e., SubjectPublicKeyInfo
), and the function is documented at http://www.opensource.apple.com/source/Security/Security-55163.44/sec/Security/SecRSAKey.c.
PKCS#1 is an ASN.1 encoding of the public key (i.e., SubjectPublicKeyInfo
). That format is fine for pinning. For those who are not familiar, pinning is a whitelist of expected certificates or public keys for a host. They are usually interchangeable when identifying a host, but there are occasions where they are not. For example, Google's public keys are static (fixed), but Google rotates the 'outer' X509 certificate. In this case, you would pin the public key, and not the certificate.
What are the proper headers and frameworks for SecRSAPublicKeyCopyPublicSerialization
? I have included Security.framework
, but the declaration for SecRSAPublicKeyCopyPublicSerialization
is missing, and the function is missing during link. I did try to include SecRSAKey.h
.
Sorry about the crummy tags.
Jeff