diff --git a/Sources/NIOSSL/ByteBufferBIO.swift b/Sources/NIOSSL/ByteBufferBIO.swift index 6fd72366..8418a4f4 100644 --- a/Sources/NIOSSL/ByteBufferBIO.swift +++ b/Sources/NIOSSL/ByteBufferBIO.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + #if canImport(Darwin) import Darwin.C #elseif canImport(Musl) diff --git a/Sources/NIOSSL/CustomPrivateKey.swift b/Sources/NIOSSL/CustomPrivateKey.swift index f33b2132..836c59ee 100644 --- a/Sources/NIOSSL/CustomPrivateKey.swift +++ b/Sources/NIOSSL/CustomPrivateKey.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + /// ``NIOSSLCustomPrivateKey`` defines the interface of a custom, non-BoringSSL private key. /// /// In a number of circumstances it is advantageous to store a TLS private key in some form of high-security storage, diff --git a/Sources/NIOSSL/NIOSSLHandler.swift b/Sources/NIOSSL/NIOSSLHandler.swift index 87ca4b22..520bf9c5 100644 --- a/Sources/NIOSSL/NIOSSLHandler.swift +++ b/Sources/NIOSSL/NIOSSLHandler.swift @@ -12,10 +12,15 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore import NIOTLS +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + /// The base class for all NIOSSL handlers. /// /// This class cannot actually be instantiated by users directly: instead, users must select diff --git a/Sources/NIOSSL/ObjectIdentifier.swift b/Sources/NIOSSL/ObjectIdentifier.swift index 96b28ce7..02886d00 100644 --- a/Sources/NIOSSL/ObjectIdentifier.swift +++ b/Sources/NIOSSL/ObjectIdentifier.swift @@ -12,8 +12,13 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +internal import CNIOBoringSSLShims +#else @_implementationOnly import CNIOBoringSSL @_implementationOnly import CNIOBoringSSLShims +#endif /// A representation of an ASN.1 Object Identifier (OID) public struct NIOSSLObjectIdentifier { diff --git a/Sources/NIOSSL/SSLCallbacks.swift b/Sources/NIOSSL/SSLCallbacks.swift index c42b92fe..a0aefde3 100644 --- a/Sources/NIOSSL/SSLCallbacks.swift +++ b/Sources/NIOSSL/SSLCallbacks.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + #if canImport(Darwin) import Darwin.C #elseif canImport(Musl) diff --git a/Sources/NIOSSL/SSLCertificate.swift b/Sources/NIOSSL/SSLCertificate.swift index 26271861..337b7c5a 100644 --- a/Sources/NIOSSL/SSLCertificate.swift +++ b/Sources/NIOSSL/SSLCertificate.swift @@ -12,9 +12,15 @@ // //===----------------------------------------------------------------------===// +import NIOCore + +#if compiler(>=6.1) +internal import CNIOBoringSSL +internal import CNIOBoringSSLShims +#else @_implementationOnly import CNIOBoringSSL @_implementationOnly import CNIOBoringSSLShims -import NIOCore +#endif #if canImport(Darwin) import Darwin.C diff --git a/Sources/NIOSSL/SSLCertificateExtensions.swift b/Sources/NIOSSL/SSLCertificateExtensions.swift index 18b98ee0..528735c9 100644 --- a/Sources/NIOSSL/SSLCertificateExtensions.swift +++ b/Sources/NIOSSL/SSLCertificateExtensions.swift @@ -12,8 +12,13 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +internal import CNIOBoringSSLShims +#else @_implementationOnly import CNIOBoringSSL @_implementationOnly import CNIOBoringSSLShims +#endif extension NIOSSLCertificate { public struct _Extensions { diff --git a/Sources/NIOSSL/SSLConnection.swift b/Sources/NIOSSL/SSLConnection.swift index fa44b792..acdcbc65 100644 --- a/Sources/NIOSSL/SSLConnection.swift +++ b/Sources/NIOSSL/SSLConnection.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + internal let SSL_MAX_RECORD_SIZE = 16 * 1024 /// This is used as the application data index to store pointers to `SSLConnection` objects in diff --git a/Sources/NIOSSL/SSLContext.swift b/Sources/NIOSSL/SSLContext.swift index 49782554..32947470 100644 --- a/Sources/NIOSSL/SSLContext.swift +++ b/Sources/NIOSSL/SSLContext.swift @@ -12,9 +12,15 @@ // //===----------------------------------------------------------------------===// +import NIOCore + +#if compiler(>=6.1) +internal import CNIOBoringSSL +internal import CNIOBoringSSLShims +#else @_implementationOnly import CNIOBoringSSL @_implementationOnly import CNIOBoringSSLShims -import NIOCore +#endif #if canImport(Darwin) import Darwin.C diff --git a/Sources/NIOSSL/SSLErrors.swift b/Sources/NIOSSL/SSLErrors.swift index e9b5db98..9522c437 100644 --- a/Sources/NIOSSL/SSLErrors.swift +++ b/Sources/NIOSSL/SSLErrors.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + /// Wraps a single error from BoringSSL. public struct BoringSSLInternalError: Equatable, CustomStringConvertible, Sendable { private enum Backing: Hashable { diff --git a/Sources/NIOSSL/SSLInit.swift b/Sources/NIOSSL/SSLInit.swift index 3ddecc3b..d2055aad 100644 --- a/Sources/NIOSSL/SSLInit.swift +++ b/Sources/NIOSSL/SSLInit.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif /// Initialize BoringSSL. Note that this function IS NOT THREAD SAFE, and so must be called inside /// either an explicit or implicit dispatch_once. diff --git a/Sources/NIOSSL/SSLPKCS12Bundle.swift b/Sources/NIOSSL/SSLPKCS12Bundle.swift index f4eece87..f5871ae9 100644 --- a/Sources/NIOSSL/SSLPKCS12Bundle.swift +++ b/Sources/NIOSSL/SSLPKCS12Bundle.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif /// A container for a single PKCS#12 bundle. /// diff --git a/Sources/NIOSSL/SSLPrivateKey.swift b/Sources/NIOSSL/SSLPrivateKey.swift index 09384970..353ac352 100644 --- a/Sources/NIOSSL/SSLPrivateKey.swift +++ b/Sources/NIOSSL/SSLPrivateKey.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif /// An ``NIOSSLPassphraseCallback`` is a callback that will be invoked by NIOSSL when it needs to /// get access to a private key that is stored in encrypted form. diff --git a/Sources/NIOSSL/SSLPublicKey.swift b/Sources/NIOSSL/SSLPublicKey.swift index 86f749ce..d35a7d80 100644 --- a/Sources/NIOSSL/SSLPublicKey.swift +++ b/Sources/NIOSSL/SSLPublicKey.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif /// A ``NIOSSLPublicKey`` is an abstract handle to a public key owned by BoringSSL. /// diff --git a/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift b/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift index 34273b3f..88badcf0 100644 --- a/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift +++ b/Sources/NIOSSL/SecurityFrameworkCertificateVerification.swift @@ -11,9 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + // We can only use Security.framework to validate TLS certificates on Apple platforms. #if canImport(Darwin) import Dispatch diff --git a/Sources/NIOSSL/SubjectAlternativeName.swift b/Sources/NIOSSL/SubjectAlternativeName.swift index 425b5bb1..87dff11d 100644 --- a/Sources/NIOSSL/SubjectAlternativeName.swift +++ b/Sources/NIOSSL/SubjectAlternativeName.swift @@ -12,9 +12,15 @@ // //===----------------------------------------------------------------------===// +import NIOCore + +#if compiler(>=6.1) +internal import CNIOBoringSSL +internal import CNIOBoringSSLShims +#else @_implementationOnly import CNIOBoringSSL @_implementationOnly import CNIOBoringSSLShims -import NIOCore +#endif #if canImport(Darwin) import Darwin.C diff --git a/Sources/NIOSSL/SwiftCrypto/Zeroization.swift b/Sources/NIOSSL/SwiftCrypto/Zeroization.swift index a49d0428..c033839c 100644 --- a/Sources/NIOSSL/SwiftCrypto/Zeroization.swift +++ b/Sources/NIOSSL/SwiftCrypto/Zeroization.swift @@ -11,7 +11,11 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif typealias errno_t = CInt diff --git a/Sources/NIOSSL/TLSConfiguration.swift b/Sources/NIOSSL/TLSConfiguration.swift index d0a60c35..b666c048 100644 --- a/Sources/NIOSSL/TLSConfiguration.swift +++ b/Sources/NIOSSL/TLSConfiguration.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + /// Known and supported TLS versions. public enum TLSVersion: Sendable { case tlsv1 diff --git a/Sources/NIOSSL/UnsafeKeyAndChainTarget.swift b/Sources/NIOSSL/UnsafeKeyAndChainTarget.swift index d1d35b80..9da58f65 100644 --- a/Sources/NIOSSL/UnsafeKeyAndChainTarget.swift +++ b/Sources/NIOSSL/UnsafeKeyAndChainTarget.swift @@ -11,7 +11,11 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif enum UnsafeKeyAndChainTarget { case sslContext(OpaquePointer) diff --git a/Tests/NIOSSLTests/ByteBufferBIOTest.swift b/Tests/NIOSSLTests/ByteBufferBIOTest.swift index e627bc03..be18b473 100644 --- a/Tests/NIOSSLTests/ByteBufferBIOTest.swift +++ b/Tests/NIOSSLTests/ByteBufferBIOTest.swift @@ -12,12 +12,17 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore import XCTest @testable import NIOSSL +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + final class ByteBufferBIOTest: XCTestCase { override func setUp() { guard boringSSLIsInitialized else { diff --git a/Tests/NIOSSLTests/CustomPrivateKeyTests.swift b/Tests/NIOSSLTests/CustomPrivateKeyTests.swift index 2185d10c..ee89d0ff 100644 --- a/Tests/NIOSSLTests/CustomPrivateKeyTests.swift +++ b/Tests/NIOSSLTests/CustomPrivateKeyTests.swift @@ -20,7 +20,11 @@ import XCTest @testable import NIOSSL #if compiler(>=5.1) +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else @_implementationOnly import CNIOBoringSSL +#endif #else import CNIOBoringSSL #endif diff --git a/Tests/NIOSSLTests/NIOSSLALPNTest.swift b/Tests/NIOSSLTests/NIOSSLALPNTest.swift index 998a460c..1cfcab0e 100644 --- a/Tests/NIOSSLTests/NIOSSLALPNTest.swift +++ b/Tests/NIOSSLTests/NIOSSLALPNTest.swift @@ -12,13 +12,18 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore import NIOPosix import NIOSSL import NIOTLS import XCTest +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + class NIOSSLALPNTest: XCTestCase { static var cert: NIOSSLCertificate! static var key: NIOSSLPrivateKey! diff --git a/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift b/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift index 82654888..b2e4a432 100644 --- a/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift +++ b/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOConcurrencyHelpers import NIOCore import NIOEmbedded @@ -22,6 +21,12 @@ import XCTest @testable import NIOSSL +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + public func assertNoThrowWithValue( _ body: @autoclosure () throws -> T, defaultValue: T? = nil, diff --git a/Tests/NIOSSLTests/NIOSSLTestHelpers.swift b/Tests/NIOSSLTests/NIOSSLTestHelpers.swift index 494186e0..20a637de 100644 --- a/Tests/NIOSSLTests/NIOSSLTestHelpers.swift +++ b/Tests/NIOSSLTests/NIOSSLTestHelpers.swift @@ -12,13 +12,18 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import Foundation import NIOCore import NIOEmbedded @testable import NIOSSL +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + let samplePemCert = """ -----BEGIN CERTIFICATE----- MIIGGzCCBAOgAwIBAgIJAJ/X0Fo0ynmEMA0GCSqGSIb3DQEBCwUAMIGjMQswCQYD diff --git a/Tests/NIOSSLTests/ObjectIdentifierTests.swift b/Tests/NIOSSLTests/ObjectIdentifierTests.swift index efd6b347..6727534a 100644 --- a/Tests/NIOSSLTests/ObjectIdentifierTests.swift +++ b/Tests/NIOSSLTests/ObjectIdentifierTests.swift @@ -12,11 +12,16 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import XCTest @testable import NIOSSL +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + private final class OIDMemoryOwner { var reference: OpaquePointer! public init?(_ string: String) { diff --git a/Tests/NIOSSLTests/TLSConfigurationTest.swift b/Tests/NIOSSLTests/TLSConfigurationTest.swift index f9a0f2b1..e389f656 100644 --- a/Tests/NIOSSLTests/TLSConfigurationTest.swift +++ b/Tests/NIOSSLTests/TLSConfigurationTest.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -@_implementationOnly import CNIOBoringSSL import NIOCore import NIOEmbedded import NIOPosix @@ -21,6 +20,12 @@ import XCTest @testable import NIOSSL +#if compiler(>=6.1) +internal import CNIOBoringSSL +#else +@_implementationOnly import CNIOBoringSSL +#endif + #if compiler(>=5.8) @preconcurrency import Dispatch #else