J'essaie de mettre à jour le code qui surveille une boîte aux lettres Exchange Server afin qu'elle puisse se connecter en utilisant SSL. Cependant, quand il tente de se connecter, je reçois l'erreur: The handshake failed due to an unexpected packet format.
Échec de la prise de contact en raison d'un format de paquet inattendu se connectant à Pop3
Mon code de connexion est ci-dessous (avec l'exploitation forestière et les commentaires supprimés):
ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;
try
{
tcpClient = new TcpClient(Host, Port);
}
catch (SocketException e) { ... }
try
{
var stream = client.GetStream();
ssl = new SslStream(stream);
ssl.AuthenticateAsClient(Host, null, SslProtocols.Tls, true);
streamReader = new StreamReader(ssl);
response = streamReader.ReadLine();
if (response.StartsWith("+OK"))
{
response = SendReceive("USER ", UserName.Trim() + "@" + Domain.Trim());
if (response.StartsWith("+OK"))
{
response = SendReceive("PASS ", Password);
}
}
if (response.StartsWith("+OK"))
result = true;
}
catch (Exception e) { ... }
de l'exploitation forestière, je l'ai mis le doigt sur l'exception quelque part dans les 4 premières lignes après la seconde tentative (qui est en fait dans la méthode GetStreamReader, mais je l'ai combiné pour la brièveté et la lisibilité).
L'exception que je reçois est ci-dessous:
--- Exception ---
Error: 3/8/2016 10:32:35 AM The handshake failed due to an unexpected packet format.
Info: 3/8/2016 10:32:35 AM There was an error connecting to the account.
The server returned
The handshake failed due to an unexpected packet format.
Info: 3/8/2016 10:32:35 AM Source: System
Info: 3/8/2016 10:32:35 AM Method: Void StartReadFrame(Byte[], Int32, System.Net.AsyncProtocolRequest)
Info: 3/8/2016 10:32:35 AM
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
at POP3_Communication.Pop3.GetStreamReader(TcpClient client)
at POP3_Communication.Pop3.Connect()
Copie possible de [System.IO.IOException: l'établissement de la liaison a échoué en raison d'un format de paquet inattendu?] (Http://stackoverflow.com/questions/5178757/system-io-ioexception-the-handshake-failed- dû-à-un-inattendu-paquet-format) –