SSL handshake error on self-signed cert in Flutter
You can get a valid SSL certificate for free from https://letsencrypt.org/
In my case I got this error message, because I did not specify hostname when asked for Common Name, when creating self signed certificate (localhost is OK for simple tests):
$ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.pem
Country Name (2 letter code) [AU]:SI
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:localhost
Email Address []:
I used HttpClient.badCertificateCallback
Here is a code to accept any cert:
_client = new HttpClient();
_client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;