This project is read-only.

FTP SSL Implicit failed with error "AuthenticationException: A call to SSPI failed"

Jun 18, 2014 at 7:18 PM
Hi Alex,

I really love this library and using it for my application that works with FTP. Recently, our client wants to support FTP with SSL and we got a problem with it.
For investigating, I created a console application and ran the code to test connection, download files from a FTP Server with Implicit SSL and it worked perfectly on live server. However, when I ran my application on the server (Windows Form VB.Net 4.5) that ran a background thread to do the same work as above (connect & download files from that FTP with Implicit SSL) but it failed with below error. Also, I tried to run the app on my local machine => it worked perfectly.
Could you please help me to check this and give me your advices when you have chance to check?

Many thanks,
Doanh

System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
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.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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 AlexPilotti.FTPS.Client.FTPSClient.CreateSSlStream(Stream s, Boolean leaveInnerStreamOpen) in e:\data from D\Neil Britto\SVN04102013\trunk\ETECH.EDI\FTPSClient\FTPSClient.cs:line 1794
at AlexPilotti.FTPS.Client.FTPSClient.SwitchCtrlToSSLMode() in e:\data from D\Neil Britto\SVN04102013\trunk\ETECH.EDI\FTPSClient\FTPSClient.cs:line 1771
at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData, EDataConnectionMode dataConnectionMode, String account) in e:\data from D\Neil Britto\SVN04102013\trunk\ETECH.EDI\FTPSClient\FTPSClient.cs:line 558
at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, Boolean isActiveTransferMode, String account) in e:\data from D\Neil Britto\SVN04102013\trunk\ETECH.EDI\FTPSClient\FTPSClient.cs:line 433
at ETECH.EDI.Library.Ftp.FtpsHelper.DownloadFile(String remoteFile, String localFile, FtpInfoBase ftpInfo, Boolean allowOverrideExistedLocalFile, String& errorMessage) in e:\data from D\Neil Britto\SVN04102013\trunk\ETECH.EDI\ETECH.EDI.Library.Ftp\FtpsHelper.cs:line 309.
Jan 30, 2015 at 5:08 PM
Hi everyone,

I am having the same problem, and after a lot of investigation, I found out that the problem occurs only from windows server 2012
It is not happening in windows server 2008 or in Windows 7.

The error messages receiving are:

A call to SSPI failed, see inner exception.

with inner exception:
The message received was unexpected or badly formatted

And this error is occurring during the call of .GetListing() method. (connection succeeds)

Can anyone help please?
Thanks in advance