I am trying to connect & exchange data with IMAP server using SSL.
IMAP has command for logging in. Ex:
A100 LOGIN "abc" "agc"
I am using following code to do this...
m_pSocket.Connect( m_pobjIMapServerIPAddress, 993);
m_pNetworkStream = new System.Net.Sockets.NetworkStream( m_pSocket
);
System.Net.Security.RemoteCertificateValidationCallback
objRemoteCertificateValidationCallback =
new
System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
System.Net.Security.LocalCertificateSelectionCallback
objLocalCertificateSelectionCallback =
new
System.Net.Security.LocalCertificateSelectionCallback(SelectLocalCertificate);
System.Net.Security.SslStream m_objSllStream = new
System.Net.Security.SslStream(m_pNetworkStream, true,
objRemoteCertificateValidationCallback,
objLocalCertificateSelectionCallback);
sCmd = "A123" + " LOGIN " + "username" + " " + "Password";
m_objSllStream.Write(System.Text.Encoding.ASCII.GetBytes(sCmd.ToCharArray()),
0, sCmd.Length); /// I get crash here
My questions are..
I think, when the server sends security certificate to client, I should
get callback.
But none of my callbacks are getting called.
Pls let me know which objects to use & how to use.
Thanks
Ramesh
Dominick Baier [DevelopMentor] - 28 Jan 2006 00:36 GMT
Hi,
before you can exchange data you have to call SslStream.AuthenticateAsClient.
---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com
> I am trying to connect & exchange data with IMAP server using SSL.
> IMAP has command for logging in. Ex:
[quoted text clipped - 31 lines]
> Thanks
> Ramesh
asnowfall@gmail.com - 30 Jan 2006 20:26 GMT
Thank you. AuthenticateAsClient() helped me progress a bit; still I
have a problem because password is NOT getting encrypted.
Here are the details...
if(m_objSllStream.IsEncrypted == true)
{
m_objSllStream.Write("A100 LOGIN "abc" "agc"");
//This is LOGIN command to IMAP with
//clear text Username & Password.
//LOGIN command fails with error "NO Clear text passwords
//have been disabled for this protocol"
}
My doubts are..
Does not SSlStream::Write(data) encrypt the 'data'?
Am I supposed to do some more settings.
Thanks
Ramesh