我正在尝试使用自签名证书在GCDAsyncSocket中实现安全性。在调用startTLS之后,没有调用didReceiveTrust方法。
SecIdentityRef identityRef = nil;
NSArray *certs = [[NSArray alloc] initWithObjects:(__bridge id)identityRef, nil];
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:3];
[settings setObject:[NSNumber numberWithInteger:0] forKey:GCDAsyncSocketSSLProtocolVersionMax];
[settings setObject:[NSNumber numberWithBool:YES] forKey:GCDAsyncSocketManuallyEvaluateTrust];
[settings setObject:certs forKey:GCDAsyncSocketSSLCertificates];
答案 0 :(得分:0)
您没有显示正在使用settings
的位置。
在致电startTLS
时,您必须将GCDAsyncSocketManuallyEvaluateTrust
设为@YES
:
[self.socket startTLS:@{GCDAsyncSocketManuallyEvaluateTrust: @YES}];
相关文档:http://cocoadocs.org/docsets/CocoaAsyncSocket/7.4.1/Classes/GCDAsyncSocket.html#//api/name/startTLS: