httpwebrequest不将客户端证书发送到服务器 [英] httpwebrequest not sending client certificate to server
问题描述
您好,
感谢您参与时间阅读本文。
我想做什么 :
尝试将客户端证书从控制台应用程序发送到asp.net应用程序,以便从asp.net应用程序中我可以从http请求中查看客户端的证书并进行身份验证和授权决策。
问题陈述:
Fiddler没有显示从控制台应用程序和asp.net应用程序发送的任何证书,< clientcertificate> .IsPresent返回false。在控制台应用程序中,我得到403(禁止)。
以下是详细信息
在Machine1上,我有一个控制台应用程序,它执行以下操作:
- 从证书存储区访问证书并将其添加到ClientCertificates httpwebrequest的集合,然后执行.GetResponse。我已经确定证书在.GetResponse被称为
之前的集合中可用,因此排除了客户端的权限问题。以下是代码片段:
X509Certificate2 cert = GetCertFromStore(" cert123" );
var req =(HttpWebRequest)WebRequest.Create(" https://www.wa的.com / Default.aspx的" 跨度>);
req.ClientCertificates.Add(cert);
var resp = req.GetResponse();
// ...
我有些感到困惑,这篇文章在一周内没有收到任何回复。我的印象是,微软MVP定期访问这些论坛,以帮助那些遇到微软工具和技术问题的开发人员。
如果有人觉得我发布了错误的区域,请放手我知道,所以我可以把它移到社交论坛的适当区域。
谢谢你。
Hello,
Thank you for taking the time to read this.
What I am trying to do :
Trying to send a client certificate from a console application to an asp.net application so that from the asp.net application I can peek into the client's certificate from the http request and make authentication and authorization decisions.
Problem Statement:
Fiddler does not show any certificate being sent from the console application and in the asp.net application, <clientcertificate>.IsPresent returns a false. On the console application, I get a 403 (forbidden).
Here are the details
On Machine1, I have a console application that does the following:
- Accesses a certificate from the certificate store and adds it to the ClientCertificates collection of httpwebrequest and then does a .GetResponse. I have established that the certificate is available in the collection just before the .GetResponse is called and have therefore ruled out permission problems on the client side.The following is a code snippet:
X509Certificate2 cert = GetCertFromStore("cert123"); var req = (HttpWebRequest)WebRequest.Create("https://www.wa.com/default.aspx"); req.ClientCertificates.Add(cert); var resp = req.GetResponse(); // ...
I am somewhat baffled that this post has not received any response in over a week. I was under the impression that Microsoft MVPs regularly visited these forums to assist developers who run into issues with Microsoft tools and technologies.
If someone feels I have posted in the wrong area, please do let me know so that I can move it to the appropriate area of the social forum.
Thank you.
这篇关于httpwebrequest不将客户端证书发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!