views:

473

answers:

2

Now I have a certificate which includes a public key,i want to get the public key from it in iPhone SDK programming, and encrypt a string by RSA with the public key.What should i do? Please help me!!Thanks very much.

A: 

I have the same problem...

Pablo Alejandro
A: 
SecKeyRef publicKeyReference = NULL;
NSMutableDictionary* queryPublicKey;

SecItemCopyMatching((CFDictionaryRef)queryPublicKey, (CFTypeRef *)&publicKeyReference);

publicKeyReference - is your public key representation; queryPublicKey - is your certificate representation; SecItemCopyMatching - function that allows you to retrieve public key from certificate!

Aston