loginpogin
Дата: 30.05.2008 15:21:31
есть https ресурс... при обращении к нему используется сертификат и выскакивает окно(не форма) авторизации. Рабочие сертификаты и пароли есть. Но как только я пытаюсь обратиться из asp он мне пишет ошибку:
Удаленный сервер возвратил ошибку: (401) Несанкционированный. Помогите плз,очень нужно!!! спасибо заранее. Ниже код обращения.
protected void Button2_Click(object sender, EventArgs e)
{
try
{
System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(foo);
String URL = https://sommesite.ru;
X509Certificate crt = new X509Certificate(@"c:/02929.p12", "123456");
Uri clearstream = new Uri(URL);
Encoding encoding = Encoding.Default;
HttpWebRequest httpGET = (HttpWebRequest)WebRequest.Create(clearstream);
httpGET.Method = "POST";
httpGET.Proxy.Credentials = new NetworkCredential("$02929", "123456");
httpGET.ClientCertificates.Add(crt);
httpGET.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
HttpWebResponse response = (HttpWebResponse)httpGET.GetResponse();
StreamReader sReader = new StreamReader(response.GetResponseStream(), encoding);
String resp = sReader.ReadToEnd();
response.Close();
TextBox4.Text = resp;
}
catch (Exception ex)
{
TextBox4.Text = "Ошибка: " + ex.Message;
}
}
static bool foo(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
{
// check the problem in SslPolicyErrors Enumeration
return true;
}