我已使用ASyncSocket成功连接我的服务器和套接字连接。现在我正在尝试进行SSL握手以将服务器与SSL连接。知道怎么办吗?
答案 0 :(得分:2)
AsyncSocket的ConnectTest示例显示了如何实现安全设置。
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port {
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:3];
[settings setObject:@"www.paypal.com" forKey:(NSString *)kCFStreamSSLPeerName];
[sock startTLS:settings];
// To connect to a test server, with a self-signed certificate, use settings similar to this:
// // Allow expired certificates
// [settings setObject:[NSNumber numberWithBool:YES]
// forKey:(NSString *)kCFStreamSSLAllowsExpiredCertificates];
//
// // Allow self-signed certificates
// [settings setObject:[NSNumber numberWithBool:YES]
// forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
//
// // In fact, don't even validate the certificate chain
// [settings setObject:[NSNumber numberWithBool:NO]
// forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
}