Fix InsecureConnectionBuilder (Android) and add allowInsecureConnections support (iOS/macOS)#650
Open
jrevillard wants to merge 1 commit into
Open
Conversation
…ecureConnections support for iOS/macOS Android: Replace no-op InsecureConnectionBuilder.openConnection() with real SSL bypass using TrustManager + HostnameVerifier when allowInsecureConnections=true. iOS/macOS: Add InsecureURLProtocol (NSURLProtocol subclass) that intercepts HTTPS connections and trusts all certificates. Register/unregister conditionally based on allowInsecureConnections flag. Previously, the flag was completely ignored on Apple platforms. Fixes MaikuB#386
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #386
The
allowInsecureConnectionsparameter does not work on any platform:InsecureConnectionBuilder.openConnection()is a no-op — it callsURL.openConnection()without any SSL/TLS configuration, so HTTPS connections still validate the certificate chain normally.allowInsecureConnectionsparameter is completely ignored. There is no equivalent ofInsecureConnectionBuilder, and no SSL bypass mechanism exists.This makes it impossible to use the plugin against OIDC providers with self-signed certificates during development (e.g., local Keycloak instances).
Changes
Android
Replaced the no-op
InsecureConnectionBuilder.openConnection()with a real implementation that:SSLContextwith a trust-allX509TrustManagerHostnameVerifieronHttpsURLConnectionallowInsecureConnections=true(the existing routing inFlutterAppauthPluginviagetConnectionBuilder()is unchanged)iOS & macOS
Added
InsecureURLProtocol(anNSURLProtocolsubclass) that:NSURLSessionwith emptyprotocolClassesto avoid recursionNSURLSessionAuthChallengeUseCredentialallowInsecureConnections=trueAlso added
allowInsecureConnectionsproperty toTokenRequestParametersandEndSessionRequestParameterson iOS/macOS (was previously only defined on Android).Testing
Verified on Android emulator against a local Keycloak instance with a self-signed certificate:
All operations succeed without "Network error" when
allowInsecureConnections=true.Security Note
The SSL bypass is only active when
allowInsecureConnections=trueis explicitly passed by the caller. Production configurations use CA-signed certificates andallowInsecureConnections=false(the default), so this change has no production impact.