Cordova whitelist iOS 10 SSL error: Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made

Cordova whitelist iOS 10 SSL error: Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made

我正在尝试将 ArrayBuffer 发送到

https://1511921174.cloud.vimeo.com/upload?ticket_id=xxxxxxxxxx&video_file_id=xxxxxx&signature=xxxxxxxx=1%22

在 iOS10 中没有发生任何事情。我必须有一个白名单错误。我根据 cordova-plugin-whitelist 文档将 *.vimeo.com 和 *.cloud.vimeo.com 列入白名单。 iOS 9 和 Android.

一切正常
<access origin="http://*.vimeo.com" subdomains="true" />
<access origin="https://*.vimeo.com" subdomains="true" />
<access origin="http://*.cloud.vimeo.com" subdomains="true" />
<access origin="https://*.cloud.vimeo.com" subdomains="true" />

知道会发生什么吗? 谢谢!

我必须对 iOS 10 () 的 Content-Security-Policy 元标记进行调整,因此您可能还需要 add/update,例如

<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap: file: https://*.cloud.vimeo.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; media-src *">

看来这不是白名单,而是应用传输安全问题。

我使用 iOS 10 获取要上传到 Vimeo 的视频。看起来 Vimeo 的 SSL 证书可能有问题。他们可能使用旧的 TLS 版本。当我关闭 plist 中的 App Transport Security 时,它就起作用了:

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

因此,在没有关闭所有功能的情况下,我最终只在 vimeo.com 的 plist 中添加了以下代码:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>vimeo.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSRequiresCertificateTransparency</key>
            <false/>
        </dict>
    </dict>
</dict>

希望对大家有所帮助。

之前我在 config.xml 中添加带有 edit-config 标签的 Info.Plist 个条目。 但是由于一个不明原因,当我覆盖 NsAppTransportSecurity 条目时它没有工作。

经过一些研究,我发现 cordova-plugin-whitelist 也在将 config.xml 中的 "access" 和 "allow-navigation" 标记翻译成 [=25= 中的 NsAppTransportSecurity 条目] 自 2015 年 10 月以来的文件 (source)。

所以插件阻止了我 config.xml 中的 edit-config 标签覆盖此条目。 根据 Cordova 的 this doc,您可以在 config.xml 中的 "access" 和 "allow-navigation" 标签中设置传输安全选项。 我这样做了,现在效果很好。