UATサーバー上の顧客FTPサーバーに接続してファイルをロード/アップするために、以下のコードを使用しています(.Net 2.0にする必要があります)。私はポート990を介して、彼らが提供する自己署名証明書を使用して接続する必要があります。私は私たちのUATサーバーからポート990上のURIへの接続を許可するようにファイアウォール規則を修正しました。しかしC#用のFTP over FTP
(!:))私はそれは違いはありませんタイムアウト時間を増やした場合、私はライン
Stream requestStream = request.GetRequestStream();
のタイムアウトを取得します。
私はウェブ上を見てきましたが、コードにはっきりと見当たらないものは何も見つかりませんでした。
私はその後、UATサーバーに接続するためにCuteFTPのを使用している場合は、当然、それが正常に接続して、私は手動でファイル転送を行うことができます。 WireSharkを使ってネットワークトラフィックを調べると、FTPサーバーからの応答が得られますが、useridとpwd(コードの場合)のハンドシェイクは行われませんが、CuteFTP経由でネットワークトラフィックはすべて正常です。
証明書を確認する場所にTrueを返すように強制します。
private void button4_Click(object sender, EventArgs e)
{
try
{
string completeFTPPath = ConfigurationManager.AppSettings["FTPPath"];
// get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(completeFTPPath);
request.EnableSsl = true;
request.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["FtpUserName"], ConfigurationManager.AppSettings["FtpPassword"]);
request.Method = WebRequestMethods.Ftp.UploadFile;
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
// read file into byte array
StreamReader sourceStream = new StreamReader(ConfigurationManager.AppSettings["LocalFilePath"]);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
// send bytes to server
MessageBox.Show("GetRequestStream() start");
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
MessageBox.Show("GetRequestStream() end");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
MessageBox.Show("Response status: " + response.StatusDescription);
}
catch (WebException we)
{
MessageBox.Show(we.Message);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{ return true; }
FTPPath - ftp://111.222.333.444:990/UAT/testFile.zip; FtpUserName - userID; FtpPassword = userPwd; LocalFilePath - C:\ TEMP \ testFile.zip
誰でも任意のアイデア?上記のコードを動作させる人もいるようです。 TIA。
で動作します知っていますホスト名「111.222.333.444」は「www.company.com」という名前ではなく、証明書名の照合に失敗します。これはあなたの問題だろうか? –