sslError:SslError{消息:表示评估成功并且证书隐式受信任,但未明确指定用户意图

问题描述 投票:0回答:1

我正在尝试使用启用了 Microsoft AD 登录的网页来处理基于内部电子邮件(公司用户)或外部(任何使用有效电子邮件 ID 的人)的域和非域登录,我还检查了弹出窗口和所有已为浏览器启用。

我仅在 IOS 设备上遇到以下错误,相同的 URL 和登录在设备浏览器上工作正常。

flutter: }, sslError: SslError{code: UNSPECIFIED, message: Indicates the evaluation succeeded and the certificate is implicitly trusted, but user intent was not explicitly specified.}}}

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

class CustomInAppBrowser extends StatefulWidget {
  final String url;

  const CustomInAppBrowser({super.key, required this.url});

  @override
  State<CustomInAppBrowser> createState() => _CustomInAppBrowserState();
}

class _CustomInAppBrowserState extends State<CustomInAppBrowser> {
  final GlobalKey webViewKey = GlobalKey();

  String url = '';
  String title = '';
  double progress = 0;
  bool? isSecure;
  InAppWebViewController? webViewController;

  @override
  void initState() {
    super.initState();
    url = widget.url;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            child: Stack(
              children: [
                InAppWebView(
                  key: webViewKey,
                  initialUrlRequest: URLRequest(url: WebUri(widget.url)),
                  onNavigationResponse: (controller, navigationResponse) async {
                    debugPrint('navigationResponse: ${navigationResponse}');
                    return NavigationResponseAction.ALLOW;
                  },
                  onPermissionRequest: (controller, permissionRequest) async {
                    debugPrint('permissionRequest: ${permissionRequest}');
                    return PermissionResponse.fromMap({
                      'resources': permissionRequest.resources,
                      'action': PermissionResponseAction.GRANT
                    });
                  },
                  onReceivedServerTrustAuthRequest: (InAppWebViewController controller,
                      URLAuthenticationChallenge challenge) async {
                    debugPrint('onReceivedServerTrustAuthRequest: ${challenge}');
                    return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
                  },
                  initialSettings: InAppWebViewSettings(
                    transparentBackground: true,
                    safeBrowsingEnabled: true,
                    isFraudulentWebsiteWarningEnabled: true,
                  ),
                  onWebViewCreated: (controller) async {
                    webViewController = controller;
                    if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
                      await controller.startSafeBrowsing();
                    }
                  },
                  onLoadStart: (controller, url) {
                    if (url != null) {
                      setState(() {
                        this.url = url.toString();
                        isSecure = urlIsSecure(url);
                      });
                    }
                  },
                  onLoadStop: (controller, url) async {
                    if (url != null) {
                      setState(() {
                        this.url = url.toString();
                      });
                    }

                    final sslCertificate = await controller.getCertificate();
                    setState(() {
                      isSecure = sslCertificate != null || (url != null && urlIsSecure(url));
                    });
                  },
                  onUpdateVisitedHistory: (controller, url, isReload) {
                    if (url != null) {
                      setState(() {
                        this.url = url.toString();
                      });
                    }
                  },
                  onTitleChanged: (controller, title) {
                    if (title != null) {
                      setState(() {
                        this.title = title;
                      });
                    }
                  },
                  onProgressChanged: (controller, progress) {
                    setState(() {
                      this.progress = progress / 100;
                    });
                  },
                ),
                progress < 1.0 ? LinearProgressIndicator(value: progress) : Container(),
              ],
            ),
          ),
        ],
      ),
    );
  }

  void handleClick(int item) async {
    switch (item) {
      case 0:
        await InAppBrowser.openWithSystemBrowser(url: WebUri(url));
        break;
      case 1:
        await webViewController?.clearCache();
        if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
          await webViewController?.clearHistory();
        }
        setState(() {});
        break;
    }
  }

  static bool urlIsSecure(Uri url) {
    return (url.scheme == "https") || isLocalizedContent(url);
  }

  static bool isLocalizedContent(Uri url) {
    return (url.scheme == "file" ||
        url.scheme == "chrome" ||
        url.scheme == "data" ||
        url.scheme == "javascript" ||
        url.scheme == "about");
  }
}

我还在Plist.info文件中指定了权限

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>

我仍然收到错误

我正在尝试使用 webview,并希望它能够以与直接在 iOS 移动设备的 safari 或 chrome 浏览器中工作的方式相同!!

ios flutter webview flutter-inappwebview inappwebview
1个回答
0
投票

我通过将 flutter_inappwebview 更改为 ^5.8.0 而不是 6.0.0 来修复它

© www.soinside.com 2019 - 2024. All rights reserved.