Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: ssl connect,an AuthenticationException Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jklk11640
Newbie
Newbie


Joined: 03 May 2017
Online Status: Offline
Posts: 4
Posted: 19 July 2017 at 7:06pm | IP Logged Quote jklk11640

Hi,I have a trouble.I want to create a windows service to received mails from different mail servers regular.it works fine at most time.however,it throw an exception.
there is the infomation:
MailBee v10.0
code:
for (int i = userList.Count - 1; i > -1; i--)
{
UserInfo user = userList;
Imap imp = null;
imp = new Imap(LineKey);
imp.SslMode = MailBee.Security.SslStartupMode.OnConnect;              
imp.Connect(user.Server, int.Parse(user.Port));
imp.Login(user.Account, pwd);
/*
i have checkd the params,it's ok.
*/
}
exception:
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted.
   System.Net.Security.SslState.CheckThrow(Boolean authSucessCheck)
   System.Net.Security.SslState.get_SecureStream()
   System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   a.c.u.a(Byte[] A_0, Int32 A_1)
   a.a3.k(Int32 A_0)
   a.l.a(String A_0, Int32 A_1, Boolean A_2, Socket A_3, EndPoint A_4, Int32 A_5)
   a.l.y()
   a.ab.a(Boolean A_0, String A_1, Int32 A_2, Boolean A_3, Socket A_4, EndPoint A_5)
   MailBee.ImapMail.Imap.Connect(String serverName, Int32 port)
   MailRevService.MainService.RevMailList(UserInfo user)
mailbeelog:
[16:43:08.48] [INFO] Assembly version: 10.0.2.502.
[16:43:08.48] [INFO] Will resolve host "imap.ym.163.com".
[16:43:08.48] [INFO] Host "imap.ym.163.com" resolved to IP address(es) 123.58.177.53. [16:43:08.48] [INFO] Will connect to host "imap.ym.163.com" on port 993.
[16:43:08.49] [INFO] Socket connected to IP address 123.58.177.53 on port 993. [16:43:08.49] [INFO] Will start TLS/SSL negotiation sequence.
[16:43:08.51] [INFO] TLS/SSL negotiation completed.
//then throw exception
it irregular happend.
any idea?thanks.
Back to Top View jklk11640's Profile Search for other posts by jklk11640
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 4851
Posted: 20 July 2017 at 1:17am | IP Logged Quote Igor

You're using an older version of the product, see if the issue persists with v11 of MailBee.NET Objects. You can download the installer at:

https://afterlogic.com/download/MailBeeNetObjects.msi

The latest build of the DLL can be found at:

https://afterlogic.com/updates/mailbee_net.zip

Let us know if the update helps.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
jklk11640
Newbie
Newbie


Joined: 03 May 2017
Online Status: Offline
Posts: 4
Posted: 20 July 2017 at 10:29pm | IP Logged Quote jklk11640

I tried the MailBee v11,now it throw this:

MailBee.Security.MailBeeSslNegotiationException: AuthenticationException occurred during SSL negotiation. InnerException message follows: A call to SSPI failed, see inner exception. InnerException message follows: The message received was unexpected or badly formatted. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted.
   --- 内部异常堆栈跟踪的结尾 ---
   在 System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   在 System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   在 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   在 System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   在 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   在 System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   在 System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   在 a.b.ax.a(SecurityProtocol A_0, String A_1)
   --- 内部异常堆栈跟踪的结尾 ---
   在 a.b.ax.a(SecurityProtocol A_0, String A_1)
   在 a.j.a()
   在 a.j.a(String A_0, Int32 A_1, Boolean A_2, Socket A_3, EndPoint A_4, Int32 A_5)
   在 a.j.y()
   在 a.z.a(Boolean A_0, String A_1, Int32 A_2, Boolean A_3, Socket A_4, EndPoint A_5)
   在 MailBee.ImapMail.Imap.Connect(String serverName, Int32 port)
   在 MailRevService.MainService.RevMailList(UserInfo user)

[13:23:15.37] [INFO] Assembly version: 11.1.0 build 585 for .NET 2.0.
[13:23:15.37] [INFO] Will resolve host "imap.ym.163.com".
[13:23:15.37] [INFO] Host "imap.ym.163.com" resolved to IP address(es) 123.58.177.53.
[13:23:15.37] [INFO] Will connect to host "imap.ym.163.com" on port 993.
[13:23:15.39] [INFO] Socket connected to IP address 123.58.177.53 on port 993.
[13:23:15.39] [INFO] Will start TLS/SSL negotiation sequence.
[13:23:15.41] [INFO] Error: AuthenticationException occurred during SSL negotiation. InnerException message follows: A call to SSPI failed, see inner exception. InnerException message follows: The message received was unexpected or badly formatted.
[13:23:15.41] [INFO] Will disconnect from host "imap.ym.163.com".
[13:23:15.41] [INFO] Disconnected from host "imap.ym.163.com".
Back to Top View jklk11640's Profile Search for other posts by jklk11640
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 1989
Posted: 21 July 2017 at 2:49am | IP Logged Quote Alex

H-m-m, can't reproduce this..

[12:41:16.88] [INFO] Assembly version: 11.1.0 build 585 for .NET 2.0.
[12:41:16.85] [INFO] Will resolve host "imap.ym.163.com".
[12:41:17.38] [INFO] Host "imap.ym.163.com" resolved to IP address(es) 123.58.177.53.
[12:41:17.38] [INFO] Will connect to host "imap.ym.163.com" on port 993.
[12:41:17.67] [INFO] Socket connected to IP address 123.58.177.53 on port 993.
[12:41:17.70] [INFO] Will start TLS/SSL negotiation sequence.
[12:41:18.51] [INFO] TLS/SSL negotiation completed.
[12:41:18.58] [RECV] * OK Welcome to Hmail IMAP4rev1 server (Version. 1.0)\r\n [Total 55 bytes received.]

Which Windows are you using?

Also, before calling .Connect, try setting:

imp.SslProtocol = SecurityProtocol.Tls12;

or

imp.SslProtocol = SecurityProtocol.Tls1;

Can you also try on another computer (in another network, if possible)?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
jklk11640
Newbie
Newbie


Joined: 03 May 2017
Online Status: Offline
Posts: 4
Posted: 03 August 2017 at 11:29pm | IP Logged Quote jklk11640

Hi,I've got some news.
I logged the communications between local and mailserver,then i found,if there is no exception,local received data like this:
Date                          from             to
1.2017-08-04 12:24:12.884734     123.58.177.53     10.0.0.102     TLSv1     140     Serv er Hello
2.2017-08-04 12:24:12.884734     123.58.177.53     10.0.0.102     TLSv1     60     Chang e Cipher Spec
3.2017-08-04 12:24:12.884735     123.58.177.53     10.0.0.102     TLSv1     107     Encr ypted Handshake Message
4.2017-08-04 12:24:12.884806     10.0.0.102     123.58.177.53     TCP     54     8685 → 993 [ACK] Seq=154 Ack=146 Win=65536 Len=0
5.2017-08-04 12:24:12.885283     10.0.0.102     123.58.177.53     TLSv1     113     Chan ge Cipher Spec, Encrypted Handshake Message
this is ok.
but sometiems,the order is step1->step3->step2->step4->stop,then trow an exception.
maybe,i mean,when we received the sign:Change Cipher Spec,but next we received null(the data had been received before),it course the problem?
Back to Top View jklk11640's Profile Search for other posts by jklk11640
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 1989
Posted: 04 August 2017 at 2:31am | IP Logged Quote Alex

It's hard to say what's going on exactly because we never deal with these SSL handshake internals. We're just using the standard SslStream class.

I'd try on different computers with diff. OS versions, for instance. Perhaps, something's wrong with that particular PC (because on our systems your code is working fine).

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide