From 2a439aff650ba63077cf7bed86677c739f76d782 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Mon, 9 Nov 2026 10:17:57 +0100 Subject: [PATCH] Guard `Security.framework` usage with `canImport(Security)` (#614) The certificate validation code only needs the `Security` framework, not `Darwin`. --- Sources/NIOSSL/SSLContext.swift | 2 +- Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/NIOSSL/SSLContext.swift b/Sources/NIOSSL/SSLContext.swift index 0a622bea..d2c2b839 100644 --- a/Sources/NIOSSL/SSLContext.swift +++ b/Sources/NIOSSL/SSLContext.swift @@ -536,7 +536,7 @@ public final class NIOSSLContext { let conn = SSLConnection(ownedSSL: ssl, parentContext: self) // If we need to turn on the validation on Apple platforms, do it here. - #if canImport(Darwin) + #if canImport(Security) switch self.configuration.trustRoots { case .some(.default), .none: conn.setCustomVerificationCallback( diff --git a/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift b/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift index 34273b3f..d67a3b0b 100644 --- a/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift +++ b/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift @@ -15,7 +15,7 @@ import NIOCore // We can only use Security.framework to validate TLS certificates on Apple platforms. -#if canImport(Darwin) +#if canImport(Security) import Dispatch import Foundation @preconcurrency import Security