AsyncSocket TLS HOWTO

I am new to AsyncSocket and I am desperately trying to connect it to the Facebook chat server (chat.facebook.com) on port 5222 (xmpp) and it does it very well. it worked fine before facebook switched to secure sockets.

Now the server tells me that I am running tls, so I call [socket startTLS: nil] and it does nothing. any attempt to write to the socket subsequently results in nothing. The server will stop responding, I'm not sure what I'm 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 try to connect to the server and tell me what I'm doing wrong?

thanks for the help

+4
source share
1 answer

You can take a look at XMPPFramework , it uses AsyncSocket (the same author too) for XMPP and works with Facebook chat.

0
source

Source: https://habr.com/ru/post/1379962/


All Articles