Ftp 如何修复:由于意外的数据包格式,握手失败?

Ftp 如何修复:由于意外的数据包格式,握手失败?,ftp,Ftp,我正在从Windows Server 2008 R2连接到运行vsFTPd 2.0.7的Linux FTP服务器。我通过SSL连接 下面是它失败的代码行: sslStream = new SslStream(stream, false, CertificateValidation); 以下是日志: 220 (vsFTPd 2.0.7) AUTH SSL 234 Proceed with negotiation. 我收到以下错误: System.IO.IOException: The hand

我正在从Windows Server 2008 R2连接到运行vsFTPd 2.0.7的Linux FTP服务器。我通过SSL连接

下面是它失败的代码行:

sslStream = new SslStream(stream, false, CertificateValidation);
以下是日志:

220 (vsFTPd 2.0.7)
AUTH SSL
234 Proceed with negotiation.
我收到以下错误:

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, AsyncProtocolRequest 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)

从我的谷歌搜索中,这似乎是vsftpd的常见问题。

您可以查看这篇文章以获得解决方案的提示

归结起来是:

  • 为FTPE配置vsftpd(带有显式TLS/SSL的文件传输协议)
  • 验证是否已生成SSL证书,或者在必要时生成一个SSL证书
  • 修改vsftpd.conf以允许FTPES连接/传输
  • 重新启动vsftpd以使更改生效
  • 验证您正在运行最新版本,如有必要,请升级
更新
其他要检查的内容是: 该线程使用以下代码块示例讨论隐式模式和显式模式之间的差异:

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;
}