0 votes

Hi,

I am having issue with TLS 1.2 turned on exchange server and IMAP cannot connect to the mailbox.

In the code, I have this logic

var client = new Imap();

client.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls | SslProtocols.Ssl3;

Any assistance is appreciated.

Thanks,
-Vi

Last network operation failed.
at Limilabs.Client.ClientBase.()
at Limilabs.Client.ClientBase.Send(String command)
at   .(   )
at   .(ImapCommand )
at Limilabs.Client.IMAP.Imap.(ImapCommand , Boolean )
at Limilabs.Client.IMAP.Imap.(String , FolderInfo )
at Limilabs.Client.IMAP.Imap.Select(FolderInfo folder)
at Limilabs.Client.IMAP.Imap.Select(String folder)

by

1 Answer

0 votes

1.
"Last network operation failed." exception means that you ignored some previous exceptions e.g. thrown from Connect/ConnectSSL method.

2.
Please try forcing TLS 1.2 only:

client.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12;

3.
If this server is public, may you post server address in the comments for us to check?

by (301k points)
I tried client.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12 and it did not work

unfortunately, this server is not public

did you guys test with TLS 1.2 being turned on for exchange server?
Please make sure you catch the first exception you get from Mail.dll.
What is the exception message, type and stack trace?

Additionally please turn on logging:
https://www.limilabs.com/blog/logging-in-mail-dll
here is the log using the link you sent.
it does not seem to be helpful

Mail.dll Information: 0 :  9 15:08:57 3.0.17312.2008
Mail.dll Information: 0 :  9 15:08:57 Connecting to '172.20.0.9:993', SSL: True.
What is the exception message, exception type and stack trace?

Are you sure this server support implicit SSL/TLS?
Try connecting on plain port and use StartTLS:

   imap.Connect(...);
   imap.StartTLS(...);
that's all i got for exception message i sent earlier
I tried with StartTLS but no go
1.
Exception you shown comes from Imap.Select method, not from Connect method.

2.
You need to be more specific: what happened when you connected on non-SSL port?
I am not sure there is a way to attach image here
but here is the error message

Message:
"Please connect first"

Stacktrace:
  at Limilabs.Client.ClientBase.()
   at Limilabs.Client.ClientBase.Send(String command)
   at   .(   )
   at   .(ImapCommand )
   at Limilabs.Client.IMAP.Imap.(ImapCommand , Boolean )
   at Limilabs.Client.IMAP.Imap.(   )
   at Limilabs.Client.IMAP.Imap.(   )
   at Limilabs.Client.IMAP.Imap.GetFolders()
This is from GetFolder method not from Connect.

Please use the following code:

    using(var imap = new Imap())
    {
         imap.ConnectSSL("imap.example.com");
         imap.Close();
    }
just out of curiosity, if you ever tested with TLS 1.2 and 1.1 enabled on exchange server and others are being turned off

If you do test and it worked, please post the sample codes

cause i tried different methods of connectivity and so far none of them worked for me
Yes, TLS 1.2 was tested against many servers, including Exchange used by outlook.com:

using (Imap client = new Imap())
{
    client.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12;
    client.ConnectSSL("imap-mail.outlook.com");
    client.Close();
}

Your problem is not with TLS 1.2, right now I don't know what your problem is to be honest.

All exceptions you shown are not coming from Connect method.

How does your code look like?
Can you please try using the simplest possible code I shown in the comment above?
Does it work without specifying EnabledSslProtocols?
What are the TLS/SSL version your server supports?
...