Open GoogleCodeExporter opened 8 years ago
Replacing the lines (should be around line 430 in SKPSMTPMessage.m. Can't say
exactly as I added some lines to turn on/off the NSLogs with a define)
CFWriteStreamWriteFully((CFWriteStreamRef)outputStream, (const uint8_t *)[ehlo UTF8String], [ehlo lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
[self startShortWatchdog];
with this try catch Block
@try {
CFWriteStreamWriteFully((CFWriteStreamRef)outputStream, (const uint8_t *)[ehlo UTF8String], [ehlo lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
[self startShortWatchdog];
}
@catch (NSException * e) {
[self stopWatchdog];
error = [NSError errorWithDomain:@"SKPSMTPMessageError"
code:kSKPSMTPErrorTLSFail
userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Unable to start TLS", @"")
forKey:NSLocalizedDescriptionKey]];
encounteredError = YES;
}
did help. The problem was, that the server did talk about TLS when contacted by
the iPhone, but didn't reall support it. Causing the timeout and with it an
uncaught exception that crashes the
app.
Original comment by goo...@ambertation.de
on 9 Mar 2009 at 7:30
Another thing is that if the mail server supports only SSL protocol which defer
from STL protocol implementation, you need to add the following lines of code
if ((inputStream != nil) && (outputStream != nil))
{
sendState = kSKPSMTPConnecting;
isSecure = NO;
[inputStream retain];
[outputStream retain];
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
//if (useSSL)
//{
[inputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL
forKey:NSStreamSocketSecurityLevelKey];
[outputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL
forKey:NSStreamSocketSecurityLevelKey];
NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
kCFNull,kCFStreamSSLPeerName,
nil];
CFReadStreamSetProperty((CFReadStreamRef)inputStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
CFWriteStreamSetProperty((CFWriteStreamRef)outputStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
// }
just underneath
[NSStream getStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
This way you can connect to SSL socket supported servers, since SSL sockets
must ssl hand shake first whereas TLS protocol dose not require an SSL client
socket to be created when connected to TLS enabled server. an obvious example
is that google mail server has to secure connections one for pure SSL, and the
other is for TLS protocol. see
http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
Original comment by waleed.m...@gmail.com
on 16 Jan 2011 at 10:20
Original issue reported on code.google.com by
ncia...@gmail.com
on 22 Feb 2009 at 2:55