java - 错误 : The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

标签 java macos electron

我想使用 chromedriver(java) 运行 Electron 应用程序,面临这个问题

{ [Error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.] code: -1022, domain: 'NSURLErrorDomain' } 

并且不能与应用程序内的元素交互。

MacOS Mojave 10.14.5
Chrome 驱动程序 2.46

已经尝试更改 info.plist
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsLocalNetworking</key>
  <true/>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
  <key>NSExceptionDomains</key>
  <dict>
    <key>localhost</key>
    <dict>
      <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key>
      <false/>
      <key>NSIncludesSubdomains</key>
      <false/>
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>1.0</string>
      <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
      <false/>
    </dict>
    <key>127.0.0.1</key>
    <dict>
      <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key>
      <false/>
      <key>NSIncludesSubdomains</key>
      <false/>
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>1.0</string>
      <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
      <false/>
    </dict>
  </dict>
</dict>

最佳答案

它失败的一个可能原因可能是语法问题。当我查看 iOS 应用程序时,XML 语法如下:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>0</key>
        <string>http://localhost</string>
    </dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

而不是主机名作为键。尝试将其更新为该结构并指定协议(protocol)(http)。

关于java - 错误 : The resource could not be loaded because the App Transport Security policy requires the use of a secure connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57286489/

相关文章:

macos - 如何使用 `emacsclient` 命令双击 OS X 中的 EMACS 文件来打开它?

node.js - 如何在Electron的第二个窗口中隐藏菜单?

java - 使用 fused Location Provider 获取当前位置

java - Androidplot - 设置边距和填充(调整标签)

macos - OSX - 禁用系统范围的触摸手势

ffmpeg - Windows 10 EV 代码签名不再适用于 Electron 应用程序

javascript - 如何使用 squirrel.windows 创建注册表项

java - 抛出 NullPointerException 但我不知道如何修复它。

Java 文件路径 f.exists() 始终返回 false

python netCDF4 在 Mac 操作系统上突然停止工作