STARTTLS IN IMAPX

Topics: Feature Requests, Help requests
Jun 9, 2015 at 10:13 PM
Hey I am trying to connect to server who uses 'STARTTLS' Capability. First I connect to server non SSL Port 143 then send command 'STARTTLS' and then 'LOGIN'. I get response after 'STARTTLS' as 'OK BEGIN TLS NEGOTATION NOW', but after I send 'LOGIN' I am not getting any response back. Can someone please help.
Jun 10, 2015 at 7:39 AM
Hi jabirst,
After the STARTTLS Command, you have to switch to an SslStream. I post the snipped here, that may help you.
IList<string> data=new List<string>();
if (SendAndReceive(ImapCommands.StartTLS, ref data))
{
    _ioStream = new SslStream(_client.GetStream(), false, CertificateValidationCallback, null);
    (_ioStream as SslStream).AuthenticateAsClient(_host, null, SslProtocols.Tls, false);
    _streamReader = new StreamReader(_ioStream);
    // update capabilities
    Capability();
}
I hope, this helps. Let me know, if you have further questions.

Best regards,
Michael
Coordinator
Jun 10, 2015 at 6:55 PM
Edited Jun 10, 2015 at 6:55 PM
Hi jabirst, Michael,

I will include Michael's snippet in the latest source code.

Greets,

Pavel
Jun 10, 2015 at 9:55 PM
Thanks it worked