File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ @interface XMPPStream ()
102
102
103
103
XMPPParser *parser;
104
104
NSError *parserError;
105
+ NSError *otherError;
105
106
106
107
Byte flags;
107
108
Byte config;
@@ -3373,9 +3374,16 @@ - (void)handleStreamFeatures
3373
3374
return ;
3374
3375
}
3375
3376
}
3376
- else if (![self isSecure ] && [self startTLSPolicy ] == XMPPStreamStartTLSPolicyRequired)
3377
+ else if (![self isSecure ] && [self startTLSPolicy ] == XMPPStreamStartTLSPolicyRequired)
3377
3378
{
3378
- // We can close our TCP connection now as the server doesn't support TLS.
3379
+ // We must abort the connection as the server doesn't support our requirements.
3380
+
3381
+ NSString *errMsg = @" The server does not support startTLS. And the startTLSPolicy is Required." ;
3382
+ NSDictionary *info = [NSDictionary dictionaryWithObject: errMsg forKey: NSLocalizedDescriptionKey ];
3383
+
3384
+ otherError = [NSError errorWithDomain: XMPPStreamErrorDomain code: XMPPStreamUnsupportedAction userInfo: info];
3385
+
3386
+ // Close the TCP connection.
3379
3387
[self disconnect ];
3380
3388
3381
3389
// The socketDidDisconnect:withError: method will handle everything else
@@ -4103,11 +4111,14 @@ - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err
4103
4111
4104
4112
// Notify delegate
4105
4113
4106
- if (parserError)
4114
+ if (parserError || otherError )
4107
4115
{
4108
- [multicastDelegate xmppStreamDidDisconnect: self withError: parserError];
4116
+ NSError *error = parserError ? parserError : otherError;
4117
+
4118
+ [multicastDelegate xmppStreamDidDisconnect: self withError: error];
4109
4119
4110
4120
parserError = nil ;
4121
+ otherError = nil ;
4111
4122
}
4112
4123
else
4113
4124
{
You can’t perform that action at this time.
0 commit comments