Kingfisher: Unauthorized status code using SSL connection

Hi,

first of all I really love this library. However I’m facing some troubles trying to load images with an HTTPS connection with a self signed certificate.

My current setup looks like this

let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
      "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=1.0" : "Accept",
      "Bearer \(tokens.accessToken) " : "Authorization"
]

let imgManager = ImageDownloader.default
imgManager.sessionConfiguration = configuration
imgManager.trustedHosts = Set(["staging.mywebsite.com", "api.mywebsite.com"])

KingfisherManager.shared.downloader = imgManager

However setImagealways returns with a 401 status code.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Woops, sorry forgot to update my comment. I already figured my own noobish mistake…sigh sorry for wasting your time, but thanks for responding!

Hmmm I doubt that it has something to do with a token issue, as I’m performing a couple of other requests to the server that are working. For other network requests I’m using Moya, where I set the following manager (Alamofire SessionManager)

class func trustCaCert() -> Manager {

        let policies: [String: ServerTrustPolicy] = [
            "testing.mywebsite.com": .pinCertificates(
                certificates: ServerTrustPolicy.certificates(in: Bundle(for: self)),
                validateCertificateChain: true,
                validateHost: true
            ),
            "api.mywebsite.com": .pinCertificates(
                certificates: ServerTrustPolicy.certificates(in: Bundle(for: self)),
                validateCertificateChain: true,
                validateHost: true
            )
        ]

        let manager = Manager(
            configuration: URLSessionConfiguration.default,
            serverTrustPolicyManager: ServerTrustPolicyManager(policies: policies)
        )

        return manager
}

Is there some similar option in Kingfisher?