IIS6で証明書を作成し、SSLを使用してサイトに適用しました。これで、以前に使用したのと同じプログラムが機能しなくなります。私が理解しているように、c#はHTTPSを透過的にサポートしているので、「信頼できない」証明書を使用している必要があると思います。プロキシ設定をオフにした後(403禁止エラーが発生していました)、「SSLの信頼関係を確立できませんでした」というメッセージが表示されます。
デフォルトの証明書ポリシーを検証ハックと交換するなどのいくつかの回避策を試しましたが、それは非常に古く、同じエラーが発生します。
以下は私のpostメソッドです。
try
{
HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
HttpWebRequest.DefaultCachePolicy = policy;
byte[] buffer = Encoding.UTF8.GetBytes(postData);
//Initialisation
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.Timeout = 10000;
//method is post
if (useproxy == "ON")
{
WebProxy myProxy = new WebProxy();
// Create a new Uri object.
Uri newUri = new Uri(proxy);
// Associate the new Uri object to the myProxy object.
myProxy.Address = newUri;
WebReq.Proxy = myProxy;
}
WebReq.KeepAlive = false;
WebReq.Method = "POST";
WebReq.ContentType = "application/x-www-form-urlencoded";
//The length of the buffer
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
//write, and close.
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//Get the response handle
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Console.WriteLine(WebResp.StatusCode);
Console.WriteLine(WebResp.Server);
//Do not worry about response!.
//read the response (the string), and output it.
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
vystup = _Answer.ReadToEnd();
if (vystup != "OK")
{
}
}
catch (WebException ex)
{
Console.WriteLine(ex);
}
これを解決する証明書または私のアプリまたはIISの回避策はありますか?おそらくそのC#は証明書を信頼していませんが、これはHttpsでの私の最初の試みです。
どんな情報でも大歓迎です。