我对AsyncSocket很新,我拼命想让它连接到端口5222(xmpp)上的Facebook聊天服务器(chat.facebook.com),并且它做得非常好。它曾经在facebook切换到安全套接字之前正常工作。
现在服务器告诉我start-tls,所以我调用[socket startTLS:nil]并且它什么也没做。之后任何写入套接字的尝试都不会产生任何结果。服务器将停止响应,我不确定我做错了什么。
-(void)startTLS:(id)_void
{
NSLog(@"********* StartTLS");
// Configure SSL/TLS settings
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:4];
[settings setObject:host forKey:(NSString *)kCFStreamSSLPeerName];
// 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];
[socket startTLS:settings];
}
任何具有AsyncSocket经验的人都可以尝试连接到服务器并告诉我我做错了什么吗?
感谢您的帮助