简体   繁体   中英

TIC SSL Trust Error while trying to read a txt file

I'm having this problem with reading from a txt file from a website without a certificate even though I have allowed it in Info.plist.

My Swift code looks like this:

let url = URL(string: "http://newskit.matsworld.io/domaci/text.txt")!

let task = URLSession.shared.downloadTask(with: url) { localURL, urlResponse, error in
    if let localURL = localURL {
        if let string = try? String(contentsOf: localURL) {
            print(string)
        }
    }
}

task.resume()

And the Info.plist looks like this:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>http://newskit.matsworld.io</key>
        <dict>
            <key>ExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>IncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

I'm stuck with this and can't figure it out. Thanks for help!

如果指定了IncludesSubdomainsdomain密钥应该只是没有方案( http )且没有子域的域

<key>matsworld.io</key>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM