简体   繁体   English

如何连接到 iOS 上的非安全本地主机 websocket?

[英]How to connect to a non-secure localhost websocket on iOS?

I have a Qt application which bundles a browser and an application which hosts a non-secure websocket server on port 50050. The browser tries to connect to the application via ws://127.0.0.1:50050 and this works out well on macOS.我有一个 Qt 应用程序,它捆绑了一个浏览器和一个在端口 50050 上托管非安全 websocket 服务器的应用程序。浏览器尝试通过 ws://127.0.0.1:50050 连接到该应用程序,这在 macOS 上运行良好。 On iOS, however, the connection fails.然而,在 iOS 上,连接失败。 I'd suspect this is due to iOS specific security settings – also because the dialog to allow local.network usage does not show up.我怀疑这是由于 iOS 特定的安全设置——也因为允许使用 local.network 的对话框没有出现。 Please find here the list of.network related security keys I applied in the Info.plist file请在此处找到我在 Info.plist 文件中应用的与网络相关的安全密钥列表

<key>NSLocalNetworkUsageDescription</key>
<string>Uses local networking to communicate settings…</string>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key><true/>

<key>NSAppTransportSecurity</key>
       <dict>
                <key>NSAllowsArbitraryLoads</key><true/>
                <key>NSAllowsArbitraryLoadsForMedia</key><true/>
                <key>NSAllowsArbitraryLoadsInWebContent</key><true/>
                <key>NSAllowsLocalNetworking</key><true/>
                <key>NSExceptionDomains</key>
                <dict>
                        <key>localhost</key>
                        <dict>
                                <key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
                                <key>NSIncludesSubdomains</key><true/>
                        </dict>
                        <key>mydomain.com</key>
                        <dict>
                                <key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
                                <key>NSIncludesSubdomains</key><true/>
                        </dict>
                </dict>
        </dict>

Am I missing anything in terms of security keys or does anyone have a different suggestions how to resolve this issue?我在安全密钥方面是否遗漏了任何内容,或者是否有人对如何解决此问题有不同的建议?

On iOS non-secure websockets (neither localhost) are not permitted in context with secure websites (https).在 iOS 上,在安全网站 (https) 的上下文中不允许使用非安全网络套接字(既不是本地主机)。 On OSX it is permitted for any browser except Safari. The solution is to either use non-secure websites (http) or create a secure websocket on localhost if https is required.在 OSX 上,除 Safari 之外的任何浏览器都允许使用它。解决方案是使用非安全网站 (http) 或在需要 https 时在本地主机上创建安全的 websocket。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS Safari无法连接到安全的Websocket,但可在台式机上使用 - iOS Safari fails to connect to secure websocket, but works on desktop 在iOS上的localhost上连接套接字 - Connect a socket on localhost on iOS Redis iOS客户端以安全方式使用WebSocket - Redis ios client using websocket in secure way 通过iOS上的websocket连接到XMPP? - Connect to XMPP over websocket on iOS? 从 ios 设备连接到本地主机 - Connect from ios device to localhost 如何在 iOS 上连接到真实设备上的本地主机? - How to connect to localhost on a real device in react native on iOS? 如何将iOS应用与非iOS蓝牙设备连接? - How to connect iOS app with non iOS Bluetooth devices? 非阻塞连接到环回地址(127.0.0.1 或 localhost) - Non blocking connect to loopback address (127.0.0.1 or localhost) 由于 BoringSSL 证书验证失败,iOS 上的安全 websocket 连接失败 - Secure websocket connection fails on iOS due to BoringSSL certificate verification failure React Native - 无法从@react-navigation 解析模块。 这些文件都不存在:node_modules/nanoid/non-secure/index.cjs - React Native - Unable to resolve module from @react-navigation. None of these files exist: node_modules/nanoid/non-secure/index.cjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM