Visual Studio 2005 の使用 - C# 2.0、System.Net.WebClient.UploadData(Uri address, byte[] data)
Windows Server 2003
したがって、コードの簡略化されたバージョンは次のとおりです。
static string SO_method(String fullRequestString)
{
string theUriStringToUse = @"https://10.10.10.10:443"; // populated with real endpoint IP:port
string proxyAddressAndPort = @"http://10.10.10.10:80/"; // populated with a real proxy IP:port
Byte[] utf8EncodedResponse; // for the return data in utf8
string responseString; // for the return data in utf16
WebClient myWebClient = new WebClient(); // instantiate a web client
WebProxy proxyObject = new WebProxy(proxyAddressAndPort, true);// instantiate & popuylate a web proxy
myWebClient.Proxy = proxyObject; // add the proxy to the client
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); // stick some stuff in the header
UTF8Encoding utf8Encoding = new UTF8Encoding(false);// create a utf8 encoding
Byte[] utf8EncodedRequest = HttpUtility.UrlEncodeToBytes(fullRequestString, utf8Encoding); // convert the request data to a utf8 byte array
try
{
utf8EncodedResponse = myWebClient.UploadData(theUriStringToUse, "POST", utf8EncodedRequest); // pass the utf8-encoded byte array
responseString = utf8Encoding.GetString(utf8EncodedResponse); // get a useable string out of the response
}
catch (Exception e)
{
// some other error handling
responseString = "<CommError><![CDATA[" + e.ToString() + "]]></CommError>";// show the basics of the problem
}
return responseString;// return whatever ya got
}
これは私が得るエラーです:
基になる接続が閉じられました: SSL/TLS セキュア チャネルの信頼関係を確立できませんでした。
リクエストが送信されたときに何が起こっているかを確認することはあまりできません。正しい宛先に到達していて、「証明書エラー」があると言われました。これはおそらく、私のリクエストの IP アドレスとそれが解決される URL の間に文字通りの不一致があるためです。ラウンドロビンすることになっている IP が複数あるため、URL を指定しても機能しません。私は証明書を添付していません-また、エンドポイントの所有者によると、添付することも想定されていません. 「彼ら」によると、証明書のエラーは「正常であり、無視することになっています。
問題の証明書は、サーバー上に「ちょうどそこに」ある多くのベリサイン証明書の1つであると思われます。証明書エラーを無視するために私が見た例はすべて、要求者が特定の x509 証明書を添付していることを暗示しているようです (私はそうではありません)。
.net WebServiceを調べて、ssl 検証をバイパスしました! これは私の問題を説明しています-ただし、参照する必要がある証明書(存在する場合)がわからないため、それもそうではありません。
どの証明書が問題を引き起こしているのかを実際に知らずに/気にせずにエラーを無視する方法はありますか?
そしてお願いします - 私は正確にはヘビーヒッターではないので、子供用手袋、小さな言葉、および「ダミー用」コード。
このトラフィックは専用回線を経由しているため、証明書エラーを無視することは、オープンなインターネット トラフィックほど大きな問題ではないと理解しています。