我有一个颁发给example.com的证书,但我想使用 ip 拨打电话。例如:111.111.111.111。所以我想我会这样做:
// Create Handler
using HttpClientHandler handler = new HttpClientHandler();
// Ignore certificate error
httpClientHandler.ServerCertificateCustomValidationCallback = (request, certificate, chain, sslErrors) => true;
// Create gRPCChannel
GrpcChannel channel = GrpcChannel.ForAddress(
"https://111.111.111.111",
new GrpcChannelOptions { HttpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWebText, handler) });
// Make the call
User user = await channel.CreateGrpcService<IUserService>().GetUserAsync();
这适用于.Net Framework和.Net Core,但因为它是blazor (wasm),它在浏览器上运行,所以使用ServerCertificateCustomValidationCallback会抛出PlatformNotSupportedException。
所以我的问题......有没有办法忽略来自 API 或 gRPC 调用的证书错误?(不是网站本身的证书,我知道这是不可能的)