自分のカスタムFTPクラスを実装して、自分が支払っているホストされたサーバーと連携するようにしました。 私は、アプリケーションのバックアップ、復元、および更新にFTPを使用します。 私は今、sslがこれを実稼働環境に置くことを可能にしたいと思っています。 私はホスティング会社にSSLプロトコルをサポートしているかどうか尋ねました。EnableSSLを使用したFtpWebRequest
だから私はこのような何かにマイクロソフトMSDNチュートリアルの後に私の方法を変更:今すぐ
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(m_ftpAddress.Trim()));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(m_ftpUsername, m_ftpPassword);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
X509Certificate cert = new X509Certificate(path to a certificate created with makecert.exe);
reqFTP.ClientCertificates.Add(cert);
reqFTP.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
reqFTP.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
reqFTP.EnableSsl = true;
、MSDNは、サーバーがSSLプロトコルをサポートしている場合AUTH TLSと尋ねられたとき、それは投げ、例外ではないだろうと述べています。これはトレースログに表示されます。だから私はそれがサーバーの問題ではないと思います。その後、私が手
私はfalseにSystem.Net Error: 0 : [0216] Exception in the FtpWebRequest#12547953::GetResponse - The remote server returned an error: 227 Entering Passive Mode (the IP and port number).
reqFTP.UsePassive = true;
プロパティを設定しようとした
と:
は、認証フェーズ後にサーバーがエラーをトリガ
System.Net Information: 0 : [0216] FtpControlStream#41622463 - Received response [227 Entering Passive Mode (the IP and port number).]
メッセージを返します。このエラー:
System.Net Information: 0 : [2692] FtpControlStream#4878312 - Received response [500 Illegal PORT command]
もちろん、EnableSLLプロパティをtrueに設定しなくても、問題なく動作します。
誰もがこれについて考えていますか?
編集:私は休閑ように、コードを変更:
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(m_ftpAddress.Trim()));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(m_ftpUsername, m_ftpPassword);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
ServicePointManager.ServerCertificateValidationCallback = new
System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
reqFTP.ClientCertificates.Add(cert);
reqFTP.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
reqFTP.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification
reqFTP.EnableSsl = true;
ValidateServerCertificate
は常に真を返します。この変更後、効果はありません。
と私は理解していない:
- この瞬間にアプリケーションが右、サーバー証明書を使用していますか?
- また、改造前も私のものを使用していましたか?
誰かが私の仕組みを説明できますか?
編集:多くの電子メールをホスティング会社と交換した結果、FTPソフトウェアに問題があり、コードに問題はないことが判明しました。
あなたの編集を回答として投稿し、それを受け入れます。 –