starkdmi / download_manager

Isolated download manager with progress, cancellation, pause and resume
https://pub.dev/packages/isolated_download_manager
BSD 3-Clause "New" or "Revised" License
15 stars 2 forks source link

HandshakeException #7

Closed shahmirzali49 closed 1 year ago

shahmirzali49 commented 1 year ago

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());
}
starkdmi commented 1 year ago

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

An example.

shahmirzali49 commented 1 year ago

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

starkdmi commented 1 year ago

@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);
shahmirzali49 commented 1 year ago

thanks, @starkdmi