开发者

How do I fix: The handshake failed due to an unexpected packet format?

开发者 https://www.devze.com 2022-12-22 22:38 出处:网络
I am connecting from Windows Server 2008 R2 to a Linux FTP Server running vsFTPd 2.0.7.I am connecting via SSL.

I am connecting from Windows Server 2008 R2 to a Linux FTP Server running vsFTPd 2.0.7. I am connecting via SSL.

Here is the line of code it is failing on:

sslStream = new SslStream(stream, false, CertificateValidation);

Here is the log:

220 (vsFTPd 2.0.7)
AUTH SSL
234 Proceed with negotiation.

I receive the following error:

System.IO.IOException: The handshake failed due to an unexpected packet format.
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncPr开发者_如何学JAVAotocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at KellermanSoftware.NetFtpLibrary.ProxySocket.InitSsl()
   at KellermanSoftware.NetFtpLibrary.FTP.Connect(Boolean implicitConnection)


From my google search, it appears that this is a common problem for vsftpd.
http://www.question-defense.com/2010/02/04/vsftpd-error-gnutls-error-9-a-tls-packet-with-unexpected-length-was-received

You might check out that article for hints to a solution

It boils down to:

  • Configure vsftpd for ftpes (File Transer Protocol with Explicit TLS/SSL)
  • Verifying you have an SSL certificate generated,or generate one if necessary
  • modify vsftpd.conf to allow FTPES connections/transfers
  • Restart vsftpd for the changes to take effect
  • verify you are running the latest version and upgrade if necessary

update
Something else to check out is: http://ftps.codeplex.com/Thread/View.aspx?ThreadId=63605 That thread talks about the difference between Implicit and Explicit mode with the following code block example:

private Stream GetDataStream()
{
    Stream s = null;

    if (SslSupportCurrentMode == ESSLSupportMode.Implicit)
    {
        s = dataClient.GetStream();
    }
    else if ((sslSupportCurrentMode & ESSLSupportMode.DataChannelRequested) == ESSLSupportMode.DataChannelRequested)
    {
        if (dataSslStream == null)
            dataSslStream = CreateSSlStream(dataClient.GetStream(), false);
        s = dataSslStream;
    }
    else
    {
        s = dataClient.GetStream();
    }

    return s;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号