有没有办法在 .Net 应用程序 (C#) 中获取请求的当前 SSL 证书?
我可以查看它是否是安全连接,但我无法访问 SSL 证书(X509Certificate2 或类似证书)。
我想使用此证书对字符串进行签名,而无需其他证书。
最佳答案
您需要使用 ServicePoint.Certificate Property
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://foo.com");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
response.Close();
var cert = request.ServicePoint.Certificate;
关于c# - 获取请求的 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27124439/