starkdmi/download_manager

HandshakeException

Closed this issue · 4 comments

can you disable certificate validation in http package? ( you can do optional ).

I get this error for some URLs. but I want to download it anyway cause I know there is no problem.

for disabling certificate validation example :

import 'dart:io';

class MyHttpOverrides extends HttpOverrides{
  @override
  HttpClient createHttpClient(SecurityContext? context){
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
  }
}

void main() {
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MyApp());
}

@Shahmirzali-Huseynov, can you implement this by passing the custom HttpClient?

An example.

@starkdmi Yes, I can. but How can I disable certificate validation for the Custom client?

@Shahmirzali-Huseynov, here:

import 'package:http/io_client.dart';

final httpClient = HttpClient()..badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
final ioClient = IOClient(httpClient);
await manager.init(isolates: 1, directory: directory, client: ioClient);

thanks, @starkdmi