我正在为iOS设备开发Objective-C。我需要帮助恢复SSL证书详细信息,如发行者,到期。这是我的代码所做的:
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace: (NSURLProtectionSpace*)protectionSpace
{
if([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
// get the security chain
CFIndex count = SecTrustGetCertificateCount([protectionSpace serverTrust]);
for(CFIndex i = 0; i< count; i++)
{
SecCertificateRef certificate = SecTrustGetCertificateAtIndex([protectionSpace serverTrust], i);
CFStringRef description = SecCertificateCopySubjectSummary(certificate);
NSData* data = [(NSData*)SecCertificateCopyData(certificate) autorelease];
}
但是,说明中包含主机名。如何解释使用SecCertificateCopyData获取的数据中的信息?我更喜欢使用iOS SDK。