我正在向 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/