2010-03-16 383 views
4

我从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) 

回答

1

从我的谷歌搜索,看起来这是vsftpd的常见问题。
http://www.question-defense.com/2010/02/04/vsftpd-error-gnutls-error-9-a-tls-packet-with-unexpected-length-was-received

你可以看看那篇文章的提示,以解决

它归结为:

  • 配置的vsftpd的FTPES(文件Transer协议有明确TLS/SSL)
  • 验证您是否生成了SSL证书,或者在必要时生成SSL证书
  • 修改vsftpd.conf以允许FTPES连接/传输
  • 的变化重新启动vsftpd的生效
  • 确认您运行的是最新版本的升级,如果有必要

更新
别的东西来检查的是:http://ftps.codeplex.com/Thread/View.aspx?ThreadId=63605 有关的区别在于线程会谈隐式和显式模式之间使用以下代码块示例:

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