.Net 编程:在 SSL 自签名证书上验证什么
我无法让用户为其服务器创建真正的证书,但我想进行一些安全检查。 因此,以下内容太简单了,因为在我阅读时,没有对证书进行检查。
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
您建议我让客户检查 x509 证书什么? 鉴于我使用的是 .NET 语言(c#/f#)。
I cannot get the users to create real certs for their servers but I'd like to do some security checks. So the following is too light because, as I read it, there is no checking on the certs.
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
What do you recommend that I have the clients check on the x509 cert? Given that I'm using a .NET language (c#/f#).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用自签名证书,那么您应该预期的唯一错误是根(证书颁发者)上的链错误。 我建议像这样专门捕获该链错误并让所有其他错误落空。
If you're using self signed certs then the only errors you should expect is a chain error on the root (Cert. Issuer). I would suggest something like this that traps for that chain error specifically and lets all other errors fall through.
如果您无法让客户端创建真正的证书,您至少应该尝试让他们使用您的服务器创建证书。 然后您可以检查证书是否有效或至少来自您的 CA,因为您会知道您的 CA 是否已被泄露。 如果您信任任何或所有 CA,那么实际上没有什么值得检查的。
If you can't get the clients to create real certs you should at least try to get them to create certs using your server. Then you can check that the certificate is valid or at least from your CA because you'll know if your CA has been compromised. If you're trusting any and all CAs there's really nothing worth checking.
如果您可以检查证书,您可以将自己的验证逻辑放入 ValidateRemoteCertificate 函数中
if you can check certs you could put your own validation logic in the function ValidateRemoteCertificate