https访问
想使用https访问asp.net core的API,从腾讯云上申请了免费的自签名证书,但是因为绑定的域名,用域名访问又需要备案麻烦,所以想客户端测试暂时用IP地址进行,但是在访问的时候报错。
The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
因为证书是绑定域名的,用IP地址访问会报证书校验失败,可以通过如下代码跳过客户端证书检查。
The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
因为证书是绑定域名的,用IP地址访问会报证书校验失败,可以通过如下代码跳过客户端证书检查。
HttpClientHandler clientHandler = new HttpClientHandler(); clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, SslPolicyErrors) => { return true; }; HttpClient client = new HttpClient(clientHandler);
posted @ 2023-08-05 16:41 佛西亚 阅读(287) 评论(0) 推荐(0)