I have a problem with flutter. I want to get the HTTP-Response from a website, but it doesn´t work. The example works with other websites, but not with the required website. Code:
Future initiate() async {
var client = Client();
Response response = await client.get(
‘https://www.phwt.de’
);
I get this error:
E/flutter (18017): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error:
E/flutter (18017): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:352))
The problem happens because flutter does not know who signed or issued the certificate for www.phwt.de
. The certificate seems to have been signed by SwissSign AG, to make it work you have these options:
www.phwt.de
's certificate to flutter/dart list's of trusted certificates (more info here and here ):SecurityContext clientContext = new SecurityContext()
..setTrustedCertificates(file: 'my_trusted_certificates.pem');
var client = new HttpClient(context: clientContext);
var request = await client.getUrl(Uri.parse("https://www.phwt.de"));
var response = await request.close();
client.badCertificateCallback
and checking if the signature matches (see here )true
, effectively making any certificate in the world valid (this is potentially dangerous).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.