2010-03-16 412 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; 
}