I'm working on a file share application. It's working with TCP connection between two iOS devices and I need secured connection between them. I'm using GCDAsyncSocket library for connection. I used this library for connecting other applications that accepts SSL connection before so I have no problem with client side. Here is the question; how can I host a socket that only accept SSL connection with valid SSL certificate? Thanks.
Asked
Active
Viewed 119 times
1 Answers
0
I finally solved my issue. In didAcceptNewSocket
delegate method I load my certificate with these settings.
NSDictionary *settings = @{(NSString *)kCFStreamPropertyShouldCloseNativeSocket: [NSNumber numberWithBool:YES],
(NSString *)kCFStreamSSLValidatesCertificateChain: [NSNumber numberWithBool:YES],
(NSString *)kCFStreamSSLAllowsExpiredCertificates: [NSNumber numberWithBool:NO],
(NSString *)kCFStreamSSLAllowsExpiredRoots: [NSNumber numberWithBool:NO],
(NSString *)kCFStreamSSLAllowsAnyRoot: [NSNumber numberWithBool:YES],
(NSString *)kCFStreamSSLCertificates: certificates,
(NSString *)kCFStreamSSLIsServer: [NSNumber numberWithBool:YES],
(NSString *)kCFStreamSSLLevel: (NSString *)kCFStreamSocketSecurityLevelTLSv1};

Boran
- 949
- 10
- 17