onReceivedServerTrustAuthRequest property

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebViewClient.onReceivedSslError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)'), IOSPlatform(apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), MacOSPlatform(apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), WindowsPlatform(apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected'), LinuxPlatform(apiName: 'WebKitWebView::load-failed-with-tls-errors', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.load-failed-with-tls-errors.html', note: 'Uses webkit_web_context_allow_tls_certificate_for_host() to allow proceeding with an invalid certificate.')])
FutureOr<ServerTrustAuthResponse?> Function(T controller, ServerTrustChallenge challenge)? onReceivedServerTrustAuthRequest
final

Event fired when the WebView need to perform server trust authentication (certificate validation). The host application must return either ServerTrustAuthResponse instance with ServerTrustAuthResponseAction.CANCEL or ServerTrustAuthResponseAction.PROCEED.

challenge contains data about host, port, protocol, realm, etc. as specified in the ServerTrustChallenge.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • challenge: all platforms

Use the PlatformWebViewCreationParams.isPropertySupported method to check if this property is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebViewClient.onReceivedSslError',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)',
    ),
    IOSPlatform(
      apiName: 'WKNavigationDelegate.webView',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',
      note:
          """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`.
See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details.""",
    ),
    MacOSPlatform(
      apiName: 'WKNavigationDelegate.webView',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',
      note:
          """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`.
See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details.""",
    ),
    WindowsPlatform(
      apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected',
      apiUrl:
          'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected',
    ),
    LinuxPlatform(
      apiName: 'WebKitWebView::load-failed-with-tls-errors',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.load-failed-with-tls-errors.html',
      note:
          'Uses webkit_web_context_allow_tls_certificate_for_host() to allow proceeding with an invalid certificate.',
    ),
  ],
)
final FutureOr<ServerTrustAuthResponse?> Function(
  T controller,
  ServerTrustChallenge challenge,
)?
onReceivedServerTrustAuthRequest;