NCWebImageDownloaderOperation.swift 786 B

12345678910111213141516171819
  1. //
  2. // SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import Foundation
  6. import SDWebImage
  7. @objcMembers public class NCWebImageDownloaderOperation: SDWebImageDownloaderOperation {
  8. public override func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
  9. // The pinning check
  10. if CCCertificate.sharedManager().checkTrustedChallenge(challenge) {
  11. completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
  12. } else {
  13. completionHandler(.performDefaultHandling, nil)
  14. }
  15. }
  16. }