c# ssl request - 证书验证

标签 c# ssl https nginx x509certificate

我正在向 HTTPS 请求添加自签名 X509 证书。

request.ClientCertificates.Add(new X509Certificate(@"key.pfx", ""));

它正在与 nginx 对话,使用:

 ssl_verify_client on;

因为它是自签名的,所以我在证书签名链上遇到错误。所以我告诉 c# 忽略它。 (执行lambda并返回true)

 ServicePointManager.ServerCertificateValidationCallback += 
                                (sender, cert, chain, sslPolicyErrors) => true;

但是,我随后从 nginx 收到以下错误。

400 Bad Request
No required SSL certificate was sent
nginx/1.0.5

谁能解释为什么会这样?或者我该如何查明原因?
我目前的想法:证书正在从 http 客户端中删除,因为它是自签名的?

另外:来自 c# 的一些诊断输出

Step into: Stepping over method without symbols 'System.Net.Security.SecureChannel.VerifyRemoteCertificate'
System.Net Information: 0 : [5516] SecureChannel#31534420 - Remote certificate has errors:
System.Net Information: 0 : [5516] SecureChannel#31534420 -     A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

System.Net Information: 0 : [5516] SecureChannel#31534420 - Remote certificate was verified as valid by the user.

欢迎任何帮助!谢谢, 克里斯

最佳答案

您需要在服务器上安装客户端的证书并将服务器配置为信任它。我没有使用 nginx 的经验,所以我无法帮助您如何操作,但您需要将客户端证书放入服务器的受信任证书存储区。

关于c# ssl request - 证书验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7824847/

相关文章:

c# - Jquery AJAX 与 ASP.NET WebMethod 刷新整个页面

c# - 将 SQL 注释添加到 Linq 生成的查询,以便它在 SQL 分析器中可见

https - Java EE 表单登录,负载均衡器将 https 转换为 http

javascript - 对于 Chrome 扩展,从 https 站点调用 http 站点时出现错误

c# - iis 7 https 连接到页面阻止任何 javascript 和 JQUERY

C# XML 序列化排除写类名

c# - 反射(reflection)的工作?

ssl - 如何强制或重定向我的 next.js 网站以使用 https

java - Elasticsearch - 无法初始化 SSL - 证书问题

c# - 使用公共(public)中间证书获取 Azure Function App 到 https(APIM) 端点调用的部分链异常