2011-07-27 2 views
1

FTP 서버에서 파일을 가져 와서 메모리에 저장 한 다음 HTTPS를 통해 클라이언트로 전달했습니다. 나는 모든 것을 완벽하게 작동시킨다. 여기 ASP.NET 오류가 발생하지 않고 FtpWebRequest 클래스를 사용하여 SSL을 사용할 수 없습니다.

WebException: The remote server returned an error: (500) Syntax error, command unrecognized.]
System.Net.FtpWebRequest.SyncRequestCallback(Object obj) +330
System.Net.FtpWebRequest.RequestCallback(Object obj) +23
System.Net.CommandStream.InvokeRequestCallback(Object obj) +17
System.Net.CommandStream.Abort(Exception e) +168
System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) +454
System.Net.FtpWebRequest.GetResponse() +1398

내 코드입니다 : 내가 SSL을 켜 경우, 나는 다음과 같은 오류가 나는 false로 ftp.EnableSsl을 설정하거나 그냥 주석 경우

FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(@"ftp://" + serverName + ":21/" + fileName); 
      ftp.Credentials = new NetworkCredential(userName, password); 
      ftp.UseBinary = true; 
      ftp.EnableSsl = true; 
      ftp.Method = WebRequestMethods.Ftp.DownloadFile; 
      FtpWebResponse response = null; 
      response = (FtpWebResponse)ftp.GetResponse(); 

, 그것을 잘 작동합니다 . 내가 뭘 잘못하고 있는지에 대한 아이디어. Windows XP Professional 상자에 FTP 서버에 내장 된 IIS를 사용하고 있습니다. IIS에서 디버깅 중이며 https://localhost/projectNameHere/default.aspx에서 실행 중입니다.

답변

0

서버를 신뢰할 경우 필요에 따라 유효성 검사 프로세스를 무시할 수 있습니다.

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); 

public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
{ 
    System.Diagnostics.Debug.WriteLine(certificate);    
    return true;   
} 

연결 및 데이터는 여전히 안전합니다. 소스가 신뢰할 수 있기 때문에 소스를 신뢰하지 않는 경우이 코드를 사용하지 않아야합니다.

관련 문제