I am pretty new to AsyncSocket and I'm desperately trying to get it to connect to Facebook chat server (chat.facebook.com) on port 5222 (xmpp), and it does it very well. it used to work fine before facebook switched to secure sockets.
Now the server tells me to start-tls, so I call [socket startTLS:nil] and it does nothing. any attempt to write to the socket afterwards results in nothing. The server will stop responding, I am not sure what I am doing wrong.
-(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];
}
can anyone with AsyncSocket experience can try to connect to the server and tell me what am I doing wrong ?
thanks for your help
You might want to take a look at the XMPPFramework implementation, it uses AsyncSocket (same author too) for XMPP and works with Facebook chat.