Question:
I've been using the Chilkat library for several years in some of my projects (iOS and OS X). Recently I needed to update some of them, so I also updated the Chilkat library. However, with the updated Chilkat library (both SMTP and IMAP) it seems impossible to connect using SSL.
Here's the test code:
(void)testConnection {
CkoImap *imap = [[CkoImap alloc] init];
BOOL success;
success = [imap UnlockComponent: @"Anything for 30-day trial"];
if (success != YES) {
NSLog(@"%@",imap.LastErrorText);
return;
}
imap.AutoFix = NO;
imap.Port = [NSNumber numberWithInteger:993];
imap.Ssl = YES;
imap.StartTls = NO;
imap.SslProtocol = @"default"; // Tried all possible options
// Connect to an IMAP server.
success = [imap Connect: @"mail.lekkerthuis.biz"];
if (success != YES) {
NSLog(@"%@",imap.LastErrorText);
return;
}
// Login (never gets here)
success = [imap Login: @"MeAndMyself" password: @"myPassword"];
if (success != YES) {
NSLog(@"%@",imap.LastErrorText);
return;
}
}
It fails with:
2015-11-10 11:41:47.485 IMAP-Test[1008:32633] ChilkatLog:
Connect_Imap:
DllDate: Oct 29 2015
ChilkatVersion: 9.5.0.54
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 64-bit
Language: Cocoa Objective-C
VerboseLogging: 0
connectInner:
connectToImapServer:
hostname: mail.lekkerthuis.biz
port: 993
socket2Connect:
connect2:
connectImplicitSsl:
clientHandshake:
clientHandshake2:
readHandshakeMessages:
processAlert:
TlsAlert:
level: fatal
descrip: unexpected message
--TlsAlert
Closing connection in response to fatal SSL/TLS alert.
--processAlert
Aborting handshake because of fatal alert.
--readHandshakeMessages
--clientHandshake2
--clientHandshake
Client handshake failed. (3)
--connectImplicitSsl
ConnectFailReason: 103
--connect2
--socket2Connect
failReason: 0
--connectToImapServer
connect failed.
--connectInner
Failed.
--Connect_Imap
--ChilkatLog
If I link the project with the 2012-version of the Chilkat library, it works fine.
Here's the verbose log:
2015-11-10 12:19:55.764 IMAP-Test[1262:62029] ChilkatLog:
Connect_Imap(625ms):
DllDate: Oct 29 2015
ChilkatVersion: 9.5.0.54
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 64-bit
Language: Cocoa Objective-C
VerboseLogging: 1
connectInner(625ms):
connectToImapServer(625ms):
hostname: mail.lekkerthuis.biz
port: 993
socket2Connect(625ms):
connect2(625ms):
hostname: mail.lekkerthuis.biz
port: 993
ssl: 1
connectImplicitSsl(625ms):
Clearing TLS client certificates.
connectSocket(419ms):
domainOrIpAddress: mail.lekkerthuis.biz
port: 993
connectTimeoutMs: 30000
connect_ipv6_or_ipv4(419ms):
Single-threaded domain to IP address resolution
connecting to IPV4 address...
ipAddress: 95.97.108.163
createSocket:
Setting SO_SNDBUF size
sendBufSize: 262144
Setting SO_RCVBUF size
recvBufSize: 4194304
--createSocket
connect(1ms):
Waiting for the connect to complete...
myIP: 95.97.108.164
myPort: 50512
socket connect successful.
--connect
--connect_ipv6_or_ipv4
--connectSocket
clientHandshake(206ms):
The client cert chain is NULL.
cacheClientCerts:
Cached TLS client certificates.
Client cert chain is NULL.
--cacheClientCerts
clientHandshake2(206ms):
readHandshakeMessages(201ms):
processAlert:
TlsAlert:
level: fatal
descrip: unexpected message
--TlsAlert
passiveClose:
error on socket shutdown.
socketErrno: 57
socketError: Socket is not connected
--passiveClose
--processAlert
Aborting handshake because of fatal alert.
--readHandshakeMessages
--clientHandshake2
--clientHandshake
Client handshake failed. (3)
--connectImplicitSsl
ConnectFailReason: 103
--connect2
--socket2Connect
failReason: 0
--connectToImapServer
connect failed.
--connectInner
Failed.
--Connect_Imap
--ChilkatLog
(lldb)