in iOS platform, I tried to get server's ssl certificate and have code like the following:
case NSStreamEventOpenCompleted: NSLog(@"connected"); if (aStream == self.netInputStream) { //try to verify the certificate from server. NSArray* certificates = (NSArray*)CFBridgingRelease(CFReadStreamCopyProperty((CFReadStreamRef)aStream, kCFStreamPropertySSLPeerCertificates)); if ([certificates count]>0) { SecCertificateRef certificate = (__bridge SecCertificateRef) [certificates objectAtIndex:0]; NSString * description = (NSString*)CFBridgingRelease(SecCertificateCopySubjectSummary(certificate)); //NSData* data = "" *) CFBridgingRelease(SecCertificateCopyData(certificate));
NSLog(@"description=%@",description); }
} break;
However, the Xcode said there's error
Undefined symbols for architecture i386: "_kCFStreamPropertySSLPeerCertificates", referenced from: -[DrayStream stream:handleEvent:] in DrayStream.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I checked the CFSocketStream.h it said the kCFStreamPropertySSLPeerCertificates is considered deprecated in Mac OS 10.6 and later.
My question are: 1. Is there anything wrong in my code? and how to correct it? 2. If kCFStreamPropertySSLPeerCertificates is deprecated, what's the right way to do the job?
Any help is appreciated.
regards, Kevin |