Email Server SSL Connection Problem

Hi Everybody,

I hope everyone is fine!

I am just trying to make ESJ work with Exchage 10 using SSL.

I followed Deploying an E-Mail System in Secured Mode Procedure of eSerice Deployment guide but it still not working.

I really hope anybody could help me with that.

Here is the configurarion of ESJ:

[pop-client]
address=genesys@_domain
allow-bad-msg-size=FALSE
connect-timeout=00:05:00
cycle-time=00:00:30
delete-bad-formatted-msg=FALSE
delete-big-msg=FALSE
enable-big-msg-stripping=TRUE
enable-client=TRUE
enable-debug=FALSE
endpoint=default
leave-msg-on-server=true
mailbox=genesys
maximum-msg-number=500
maximum-msg-size=5
password=_the_password
pop-connection-security=ssl-tls
port=993
protocol-timeout=00:05:00
server=_the_server
type=IMAP

As Doccumentation suggested I have also include -Djavax.net.ssl.trustStore parameter in JavaEmailServerDriver.ini file.

The .truststore file was generated by client, he also generate a .cer file.
If I try to connect using Thunderbird everything is ok (I know thunderbird use the .cer file instead of .truststore, but al least I could say connectivity is OK)

Here is the emailserver error log:
17:46:04.109 Std 20015 [MsgIn-1] JavaMail Exception.
javax.mail.MessagingException: Unable to establish handshake using SSL - server may be expecting plain text connection;
nested exception is:
javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:695)
at javax.mail.Service.connect(Service.java:381)
at com.genesyslab.icc.emailserver.MailDeliveryAgentImpl.openConnection(MailDeliveryAgentImpl.java:260)
at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.retrieveMessages(InboundMessagingClient.java:1121)
at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.run(InboundMessagingClient.java:993)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at com.genesyslab.util.concurrent16.NamedThreadFactory$1.run(NamedThreadFactory.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:245)
at com.sun.mail.iap.Protocol.(Protocol.java:116)
at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:121)
at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:710)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:659)
… 8 more

17:46:04.109 Dbg 23005 [MsgIn-1] Inbound messaging client finished.

Any idea? ???
Is any way I could verify .truststore file? ???

Thanks and regards. ;D

Import via the import tool ESJ has on it

You can check it via standard keytool utility which is provided by Java in general - on internet you can find many step-by-step description how to do it. In other hand, you can enable debugging on IMAP/POP3 protocol level to be able to track the communication between exchange server and ESJ as the client. from the posted log it seems that the used certs not matching or something like that.

Hi kubig,

As far as I could check using keytool, the .truststore I generated (based on .cer) is ok.

Here are the keytool print:
Tipo de almacÚn de claves: JKS
Proveedor de almacÚn de claves: SUN

Su almacÚn de claves contiene entrada 1

exchub01.bancocomercial.com.uy, 01/12/2015, trustedCertEntry,
Huella digital de certificado (MD5): 9D:AF:2F:74:1F:46:57:F4:00:44:2D:E3:1F:16:D
5:F3

(Sorry it is in spanish).

In the JavaEmailServerDriver.ini, the -Djavax.net.ssl.trustStore have to point to .truststore, the path have to include .truststore (file extension)?

I have no idea what else I could check…

Hi Cavagnaro,
Where can I find import ESJ tool? I searched in installation directory and further inside and I did not find it.
Thanks.

It is the tool you mentioned. Read the documentation and it describes how to do the import.
Or search about java and certificates

As far as I know, ESJ does not have keytool on it. Keytool is a JAVA tool, it does not came with ESJ distribution. Am I correct?

As I mentioned before I have used keytool to import the certificate, I used the keytool from a JAVA distribution that I have installed on my server…

You are right, just checked my ESJ new folders.

Please check my oneNote “notes” about this
http://www.filedropper.com/casodesslenimap4pop3paraemailocualquieraqueusejava

Thanks very much Cavagnaro!!

With the .java you shared and the procedure, I was able to add the certificate to my keystore! Definitely I was making some mistake with keytool…
Now it is working okay.
Just for the record, I chose to add the generated truststore to java home directory.

Thanks again!!

Regards,
Pablo.

Dear Pablo,

I am facing the same problem in ESJ dat the server requires plain text connection. Can you share the steps or procedures which you had done in your ESJ configuration. Please share that .java too as well

You can try the Java parameters:

-Dmail.imap.auth.plain.disable

Check the java doc for these parameters.

My procure is there, shared, ready to be downloaded… Can’t you read a post above? Arrgggggg how I hate lazy people like this

Yes, I did and I am unable to download the file which u have shared provided the link. Can you let me know where should i configure or add this

-Dmail.imap.auth.plain.disable

Hi rifai,

Please follow instructions shared by cavagnaro, there you will find everything you need to achieve the connection implementing SSL.
I follow this instructions and Deploying an E-Mail System in Secured Mode Procedure of eService Deployment guide.

If you have any question please post it here.

Little bit more effort please. Because of the value is Java based, it is necessary to configure it on init level - so, it means on init file level (on Windows platform) or sh file level (on linux platform). It is described in any documentation and of course, it is standard Java-based, nothing special about Genesys itself.

Kubig,

I tried with the following parameters. Still I am facing the same issue

-Dmail.imap.auth.login.disable=false
-Dmail.imap.auth.plain.disable=true

10:36:21.641 Dbg 23021 [OutSbSchd] Found 0 matching messages in database in 13 ms
10:36:21.642 Dbg 23022 [OutSbSchd] Queue size : 0 (no new messages found).
10:36:21.762 Dbg 23192 [MsgIn-1] Thread ‘MsgIn-1’ registers to shutdown notification.
10:36:21.762 Trc 21621 [MsgIn-1] Running inbound messaging client.
10:36:21.763 Dbg 29999 [MsgIn-1] factory creating impl for pop/imap server
10:36:21.767 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG: mail.imap.class property exists and points to com.sun.mail.imap.IMAPSSLStore
10:36:21.767 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: mail.imap.fetchsize: 16384
10:36:21.767 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: mail.imap.ignorebodystructuresize: false
10:36:21.767 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: mail.imap.statuscachetimeout: 1000
10:36:21.768 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: mail.imap.appendbuffersize: -1
10:36:21.768 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: mail.imap.minidletime: 10
10:36:21.768 Dbg 25112 [MsgIn-1] JavaMail POP: DEBUG IMAP: trying to connect to host “10.200.20.40”, port 993, isSSL true
10:36:21.777 Std 29997 [MsgIn-1] javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection
10:36:21.778 Std 29997 [MsgIn-1] at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:576)
10:36:21.778 Std 29997 [MsgIn-1] at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:381)
10:36:21.779 Std 29997 [MsgIn-1] at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:232)
10:36:21.779 Std 29997 [MsgIn-1] at com.sun.mail.iap.Protocol.(Protocol.java:116)
10:36:21.779 Std 29997 [MsgIn-1] at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:121)
10:36:21.780 Std 29997 [MsgIn-1] at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:710)
10:36:21.780 Std 29997 [MsgIn-1] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:659)
10:36:21.781 Std 29997 [MsgIn-1] at javax.mail.Service.connect(Service.java:381)
10:36:21.781 Std 29997 [MsgIn-1] at com.genesyslab.icc.emailserver.MailDeliveryAgentImpl.openConnection(MailDeliveryAgentImpl.java:260)
10:36:21.782 Std 29997 [MsgIn-1] at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.retrieveMessages(InboundMessagingClient.java:1121)
10:36:21.782 Std 29997 [MsgIn-1] at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.run(InboundMessagingClient.java:993)
10:36:21.783 Std 29997 [MsgIn-1] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
10:36:21.783 Std 29997 [MsgIn-1] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
10:36:21.783 Std 29997 [MsgIn-1] at com.genesyslab.util.concurrent16.NamedThreadFactory$1.run(NamedThreadFactory.java:55)
10:36:21.784 Std 29997 [MsgIn-1] at java.lang.Thread.run(Thread.java:745)
10:36:21.784 Std 20015 [MsgIn-1] JavaMail Exception.
javax.mail.MessagingException: Unable to establish handshake using SSL - server may be expecting plain text connection;
nested exception is:
javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:695)
at javax.mail.Service.connect(Service.java:381)
at com.genesyslab.icc.emailserver.MailDeliveryAgentImpl.openConnection(MailDeliveryAgentImpl.java:260)
at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.retrieveMessages(InboundMessagingClient.java:1121)
at com.genesyslab.icc.emailserver.InboundMessagingClient$SessionRunLoop.run(InboundMessagingClient.java:993)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at com.genesyslab.util.concurrent16.NamedThreadFactory$1.run(NamedThreadFactory.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:245)
at com.sun.mail.iap.Protocol.(Protocol.java:116)
at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:121)
at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:710)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:659)
… 8 more

10:36:21.785 Dbg 23005 [MsgIn-1] Inbound messaging client finished.
10:36:31.467 Dbg 23030 [TimerTask] LogReconfigureTask is now running.
10:36:31.467 Dbg 23032 [TimerTask] LogReconfigureTask cycleTime = 30000 ms.

Enable debug logging on IMAP box level (on ESJ) to see what happens within the IMAP communication, afterthat you would be able to recognize what options have to be added

Cavagnaro, hello. Can you please re-upload the files? The link has expired i think.
I am facing the same issue and i have spent a day trying to figure it out.

Well, it seems that I’m also running into this issue… cavagnaro, do you still have those notes?


23:25:37.214 Std 25080 [SvcSrvW-44] <322> Exception message: Connnection to SMTP Server host 'smtp.office365.com', port 587 failed..
23:25:37.214 Trc 25097 [SvcSrvW-44] <322> Response:
 Id=322
 Type=Fault
 AppName=DEMO_ESJ
 AppType=EMAIL_SERVER
 Service=Email
 Method=Send.
23:25:37.230 Trc 25098 [SvcSrvW-44] <322> 'Email.Send' (request id 322) handling duration : 204 ms.
23:25:37.230 Std 29997 [SvcSrvW-47] <323 023GT72RJ02FC003> javax.net.ssl.SSLException: Unable to establish handshake using SSL - server may be expecting plain text connection

It’s late, i’ll try tomorrow the following instructions from the deployment guide, Andrei Stanciu, you tried it ?

Prerequisites:
• The .truststore file has been created.

  1. Open JavaEmailServerDriver.ini in a text editor.
  2. In the [JavaArgs] section, add the following: -
    Djavax.net.ssl.trustStore=
  3. Save and close the file.

Configuring the Corporate E-mail Server
Configure TLS/SSL in the Corporate E-mail Server. Follow the constructor recommendations
to generate a certificate and configure TLS/SSL on ports POP3, IMAP and SMTP.

The following is an example of generation of a certificate with keytool (keytool is a Java
utility that is available with the JRE. The utility can be found in
<eServices_Install_Dir>/jre/bin for Unix operating systems, and in
<eServices_Install_Dir>\jre\bin for Windows operating systems):
keytool -genkey -v -alias hostname.example.com
-dname “CN=hostname.example.com,OU=IT,O=ourcompany,C=FR” -keypass
<certificate_password>
-keystore <certicate_name>.keystore -storepass <certificate_password>
-keyalg “RSA” -sigalg “SHA1withRSA” -keysize 2048 -validity 3650
The arguments used in this command are the following:
• -alias—Defines an alias in keystore, to store the key.
• -dname—Distinguished Name, a comma-separated list made up of the following, in
the following order:
◦ CN—Common Name. This must be the name of the host where the corporate e-mail server is running. It must be the host name used in E-mail Server’s settings; for example, if connecting to a POP 3 server, the option server in the pop-client section must have this value.
◦ OU—Organizational Unit Name
◦ O—Organization Name
◦ L—Locality Name (city)
◦ S—State
◦ C—Country Name

-keypass—Password of the key of the certificate.
• -keystore—Specifies the keystore used.
• -storepass—Password of the keystore.
• -keyalg—Algorithm used to generate the key. Possible values are DSA and RSA. More
information is available at http://docs.oracle.com/javase.
• -sigalg—Specifies the algorithm used to sign the key.
• -keysize—Specifies the size of the key.
• -validity—Defines the validity of the certificate, in days. The value in the example is
3,650 days, or 10 years.

By the way, I searched for a long time the “famous” keytool, and it’s under the JDK folder of java, for example ;
C:\Program Files\Java\jdk1.8.0_65\bin\keytool.exe