I am facing the first big problem with Flutter Web.
I have to login with oauth2 through a post call to my server that has a self signed ssl certificate.
Using http and dio clients to make the request, i receive net::ERR_CERT_AUTHORITY_INVALID. The only way that I found on the web is to use HttpClient, it works for android and IOs but dart:io is not working in web build. Is there a way to trust my ssl certificate for flutter web??
// My simple line of code
var response = await client.post(authorizationEndpoint.toString(), body: body, headers: headers);
// What I am looking for
var response = await client.post(authorizationEndpoint.toString(),
body: body, headers: headers,
---> trustanyCA: true);
There's no way to do that in a web version. Browser's XMLHttpRequest
just doesn't allow to bypass not trusted certificates, though it's possible to do that with other http clients.
If it's only needed for debugging purpose, you can try adding an SSL certificate to your system's trusted certificates (for macOS, drop it to System certificates in Keychain Access), as well as overriding browser's security options. Refer to this question to find out how to override it in Chrome.
For production use, you will still need a trusted valid certificate.