0

I need to convert my SWIFT code to fit HTTPS requests on private API.

I just need to understand how to make the request in Swift, at the moment changed the URL from http://...:_port/... to https://...:_port/... but I am getting those errors:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814)

nw_coretls_callback_handshake_message_block_invoke_3 tls_handshake_continue: [-9814]

nw_coretls_callback_handshake_message_block_invoke_3 tls_handshake_continue: [-9814]

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814)

I also update my info.plist to this, but still getting errors

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>domain.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>
</plist>

And this is the code

let task = session.dataTask(with: requestType as URLRequest) { (data, response, error) in
            guard let _: Data = data, let _: URLResponse = response, error == nil else {
                return
            }
            self.list   = try! JSONDecoder().decode(_myObj.self, from:data!)

        }
        task.resume()

0 Answers0