This commit is contained in:
wt committed 2026-07-30 20:07:51 +07:00
commit 92660a4ba0
228 files changed
+24496

No files matched your search

@@ -0,0 +1,24 @@
import Foundation
import Security
enum CertificateTrustEvaluator {
/// Evaluates the peer as a TLS server for the XMPP service domain.
///
/// Martin 3.2.4's legacy SocketConnector creates an SSL client-certificate
/// policy in its default path. Luma supplies the correct server policy
/// without weakening hostname or certificate-chain validation.
static func evaluateServerTrust(_ trust: SecTrust, expectedDomain: String) -> Bool {
let policy = SecPolicyCreateSSL(true, expectedDomain as CFString)
guard SecTrustSetPolicies(trust, policy) == errSecSuccess else {
return false
}
var evaluationError: CFError?
let trusted = SecTrustEvaluateWithError(trust, &evaluationError)
if !trusted, let evaluationError {
let description = CFErrorCopyDescription(evaluationError) as String
print("Luma TLS trust failed for \(expectedDomain): \(description)")
}
return trusted
}
}