Yattee v2 rewrite

This commit is contained in:
Arkadiusz Fal
2026-02-08 18:31:16 +01:00
parent 20d0cfc0c7
commit 05f921d605
1043 changed files with 163875 additions and 68430 deletions

View File

@@ -0,0 +1,29 @@
//
// InsecureURLSessionDelegate.swift
// Yattee
//
// URLSessionDelegate that bypasses SSL certificate validation.
// Used for connections to servers with self-signed or invalid certificates.
//
import Foundation
/// URLSessionDelegate that accepts all server certificates, bypassing SSL validation.
/// Only use this for trusted servers with self-signed certificates.
final class InsecureURLSessionDelegate: NSObject, URLSessionDelegate {
func urlSession(
_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void
) {
// For server trust challenges, accept the certificate without validation
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let serverTrust = challenge.protectionSpace.serverTrust {
let credential = URLCredential(trust: serverTrust)
completionHandler(.useCredential, credential)
} else {
// For other authentication methods, use default handling
completionHandler(.performDefaultHandling, nil)
}
}
}