How to fix [BoringSSL] length error in Swift 4?

Viewed 6832

I'm writing an application that gets it's data from an api and I'm getting

[BoringSSL] Function boringssl_context_get_peer_sct_list: line 1757 received sct extension length is less than sct data length

in the output window every time I make a request. I'm using this code to get the JSON:

let sampleDataAddress = "https://api.nicehash.com/api?method=stats.provider&addr=14FMY9XHC3eCvdGBvQz3a3pCwAeoar8VRz"
        let url = URL(string: sampleDataAddress)!
        let jsonData = try! Data(contentsOf: url)
        let jsonDecoder = JSONDecoder()
1 Answers

Your error it is caused because you are using Data(contentsOf: url) to download your json data synchronously and the server probably doesn't support it. You should use URLSession dataTask(with: URL) method to download your data asynchronously and this error will go away.

let url = URL(string: "https://api.nicehash.com/api?method=stats.provider&addr=14FMY9XHC3eCvdGBvQz3a3pCwAeoar8VRz")!
URLSession.shared.dataTask(with: url) { data, response, error in
    guard let data = data else { return }
    print(data.count) // you can parse your json data here
}.resume()
Related