You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Thomas Cataldo <th...@linagora.com> on 2010/02/27 17:59:07 UTC
Trouble adding TLS support to my IMAP client
Hi,
I'm maintaining an IMAP client based on Mina for the minig webmail.
I tried to add TLS support, so I added some code to my lib :
session = cf.getSession();
logger.info("Connection established");
boolean tlsActivated = run(new StartTLSCommand());
if (tlsActivated) {
activateSSL(connector);
logger.info("TLS activated.");
} else {
logger.warn("TLS not supported by IMAP server.");
}
logger.info("Sending " + login + " login informations.");
return run(new LoginCommand(login, password));
Without the tls part, everything works like a charm.
My activateSSL method is :
private void activateSSL(SocketConnector connector) {
try {
sslFilter = new MinigTLSFilter();
sslFilter.setUseClientMode(true);
connector.getDefaultConfig().getFilterChain().addFirst("TLS",
sslFilter);
logger.info("Network traffic with IMAP server will be encrypted.");
} catch (Throwable t) {
logger.error("Error starting ssl", t);
}
}
MinigTLSFilter just extends SSLFilter. It uses the
BogusSSLContextFilter factory from mina examples. Using wireshark I
can see that no ssl handshake is attempted.
Any hint on what I'm doing wrong ?
Re: Trouble adding TLS support to my IMAP client
Posted by Thomas Cataldo <th...@linagora.com>.
> MinigTLSFilter just extends SSLFilter. It uses the
> BogusSSLContextFilter factory from mina examples. Using wireshark I
> can see that no ssl handshake is attempted.
>
> Any hint on what I'm doing wrong ?
>
I found a solution using openfire source code :
private void activateSSL(SocketConnector connector) {
try {
sslFilter = new MinigTLSFilter();
sslFilter.setUseClientMode(true);
session.getFilterChain().addBefore(
"org.apache.mina.common.ExecutorThreadModel", "tls",
sslFilter);
session.setAttribute(MinigTLSFilter.DISABLE_ENCRYPTION_ONCE,
Boolean.TRUE);
logger.info("Network traffic with IMAP server will be encrypted.");
} catch (Throwable t) {
logger.error("Error starting ssl", t);
}
}
Works like a charm.