我想使用 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/