I am trying to make a request to a web api from Blazor WebASM project. The server hosting the web api is developer computer with self-signed certificate. I have configured CORS. I am trying with the follow code to bypass the certificate:
using( var httpClientHandler = new HttpClientHandler() )
{
httpClientHandler.ServerCertificateCustomValidationCallback = ( message, cert, chain, errors ) => { return true; };
using( var client = new HttpClient( httpClientHandler ) )
{
// Make your request...
}
}
Anyway I am receiving the following error:
blazor.webassembly.js:1 System.PlatformNotSupportedException: Property ServerCertificateCustomValidationCallback is not supported.
Blazor WebAssembly relies on the browser to make http requests. Under the hood, it uses the fetch
api (MDN). Web browser rejects untrusted certificates for security reasons.
The solution is to add your self-signed certificate to the certificate store of the browser or operating system. You can also start your browser with specific flags to allow untrusted certificate (not recommended as it applies to all domains).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With