import UIKit import Flutter @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } func connectionShouldUseCredentialStorage(_ connection: NSURLConnection) -> Bool { return true } func connection(_ connection: NSURLConnection, willSendRequestFor challenge: URLAuthenticationChallenge) { if let previous = challenge.previousFailureCount as? ssize_t { print(String(format: "didReceiveAuthenticationChallenge %@ %zd", challenge.protectionSpace.authenticationMethod, previous)) } if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { challenge.sender?.use(URLCredential(for: challenge.protectionSpace.serverTrust), for: challenge) challenge.sender?.continueWithoutCredential(for: challenge) } } func connection(_ connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: URLProtectionSpace) -> Bool { return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust } }