更新时间:2022-05-11 03:29:50
作为一种解决方法,您可以在客户端向 ServicePointManager
的 ServerCertificateValidationCallback
添加处理程序:
As a workaround you could add a handler to the ServicePointManager
's ServerCertificateValidationCallback
on the client side:
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
(se, cert, chain, sslerror) =>
{
return true;
};
但请注意,这不是一个好的做法,因为它完全忽略服务器证书并告诉服务点管理器任何证书都可以,这会严重危害客户端安全.您可以改进它并进行一些自定义检查(对于证书名称、哈希等).使用测试证书至少可以规避开发过程中的问题.
but be aware that this is not a good practice as it completely ignores the server certificate and tells the service point manager that whatever certificate is fine which can seriously compromise client security. You could refine this and do some custom checking (for certificate name, hash etc). at least you can circumvent problems during development when using test certificates.