diff --git a/Package.swift b/Package.swift index 52e99965..59f81403 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftNIO open source project @@ -58,10 +58,6 @@ let strictConcurrencyDevelopment = false let strictConcurrencySettings: [SwiftSetting] = { var initialSettings: [SwiftSetting] = [] - initialSettings.append(contentsOf: [ - .enableUpcomingFeature("StrictConcurrency"), - .enableUpcomingFeature("InferSendableFromCaptures"), - ]) if strictConcurrencyDevelopment { // -warnings-as-errors here is a workaround so that IDE-based development can diff --git a/README.md b/README.md index 949270d2..1db3bebe 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,7 @@ SwiftNIO SSL | Minimum Swift Version `2.23.0 ..< 2.23.2` | 5.5.2 `2.23.2 ..< 2.26.0` | 5.6 `2.26.0 ..< 2.27.0` | 5.7 -`2.27.0 ...` | 5.8 +`2.27.0 ..< 2.29.3` | 5.8 +`2.29.3 ..< 2.31.0` | 5.9 +`2.31.0 ..< 2.35.0` | 5.10 +`2.35.0 ...` | 6.0 diff --git a/Sources/NIOSSL/NIOSSLClientHandler.swift b/Sources/NIOSSL/NIOSSLClientHandler.swift index e1d52e90..f4d0a363 100644 --- a/Sources/NIOSSL/NIOSSLClientHandler.swift +++ b/Sources/NIOSSL/NIOSSLClientHandler.swift @@ -288,5 +288,8 @@ public final class NIOSSLClientHandler: NIOSSLHandler { } } +// This conformance is technically redundant - Swift 6.2 compiler finally caught this +#if compiler(<6.2) @available(*, unavailable) extension NIOSSLClientHandler: Sendable {} +#endif diff --git a/Sources/NIOSSL/NIOSSLServerHandler.swift b/Sources/NIOSSL/NIOSSLServerHandler.swift index 49a82ffb..8b2132ba 100644 --- a/Sources/NIOSSL/NIOSSLServerHandler.swift +++ b/Sources/NIOSSL/NIOSSLServerHandler.swift @@ -198,5 +198,8 @@ public final class NIOSSLServerHandler: NIOSSLHandler { } } +// This conformance is technically redundant - Swift 6.2 compiler finally caught this +#if compiler(<6.2) @available(*, unavailable) extension NIOSSLServerHandler: Sendable {} +#endif diff --git a/Sources/NIOSSL/SSLCallbacks.swift b/Sources/NIOSSL/SSLCallbacks.swift index a4b1178d..c35c1d60 100644 --- a/Sources/NIOSSL/SSLCallbacks.swift +++ b/Sources/NIOSSL/SSLCallbacks.swift @@ -320,9 +320,10 @@ extension NIOSSLContextConfigurationOverride { /// Within this callback, the user can create and return a new `NIOSSLContextConfigurationOverride` for the given host, /// and the delta will be applied to the current handshake configuration. /// -public typealias NIOSSLContextCallback = @Sendable ( - NIOSSLClientExtensionValues, EventLoopPromise -) -> Void +public typealias NIOSSLContextCallback = + @Sendable ( + NIOSSLClientExtensionValues, EventLoopPromise + ) -> Void /// A struct that provides helpers for working with a NIOSSLContextCallback. internal struct CustomContextManager: Sendable { diff --git a/Sources/NIOSSL/SSLContext.swift b/Sources/NIOSSL/SSLContext.swift index 80416b58..27e2e19b 100644 --- a/Sources/NIOSSL/SSLContext.swift +++ b/Sources/NIOSSL/SSLContext.swift @@ -139,7 +139,7 @@ private func serverPSKCallback( guard let serverCallback = parentSwiftContext.pskServerConfigurationCallback, let unwrappedIdentity = identity, // Incoming identity - let strIdentity = String(validatingUTF8: unwrappedIdentity), + let strIdentity = String(validatingCString: unwrappedIdentity), let outputPSK = psk // Output PSK key. else { return 0 @@ -198,7 +198,7 @@ private func clientPSKCallback( } // If set, build out a hint otherwise fallback to an empty string and pass it into the client callback. - let clientHint: String? = hint.flatMap({ String(validatingUTF8: $0) }) + let clientHint: String? = hint.flatMap({ String(validatingCString: $0) }) // Take the hint and pass it down to the callback to get associated PSK from callback let pskIdentity: PSKClientIdentityResponse? diff --git a/Sources/NIOSSL/SwiftCrypto/NIOSSLSecureBytes.swift b/Sources/NIOSSL/SwiftCrypto/NIOSSLSecureBytes.swift index ec08757c..d3bde7f7 100644 --- a/Sources/NIOSSL/SwiftCrypto/NIOSSLSecureBytes.swift +++ b/Sources/NIOSSL/SwiftCrypto/NIOSSLSecureBytes.swift @@ -240,8 +240,11 @@ extension NIOSSLSecureBytes { } } +// This conformance is technically redundant - Swift 6.2 compiler finally caught this +#if compiler(<6.2) @available(*, unavailable) extension NIOSSLSecureBytes.Backing: Sendable {} +#endif extension NIOSSLSecureBytes.Backing { @usableFromInline diff --git a/Sources/NIOSSL/UniversalBootstrapSupport.swift b/Sources/NIOSSL/UniversalBootstrapSupport.swift index 928a61cd..fbd1a045 100644 --- a/Sources/NIOSSL/UniversalBootstrapSupport.swift +++ b/Sources/NIOSSL/UniversalBootstrapSupport.swift @@ -123,9 +123,10 @@ public struct NIOSSLClientTLSProvider: public init( context: NIOSSLContext, serverHostname: String?, - customVerificationCallbackWithMetadata: @escaping ( - @Sendable ([NIOSSLCertificate], EventLoopPromise) -> Void - ) + customVerificationCallbackWithMetadata: + @escaping ( + @Sendable ([NIOSSLCertificate], EventLoopPromise) -> Void + ) ) throws { try self.init( context: context, diff --git a/Tests/NIOSSLTests/IdentityVerificationTest.swift b/Tests/NIOSSLTests/IdentityVerificationTest.swift index 32ec12b4..581d5ac7 100644 --- a/Tests/NIOSSLTests/IdentityVerificationTest.swift +++ b/Tests/NIOSSLTests/IdentityVerificationTest.swift @@ -114,7 +114,7 @@ class IdentityVerificationTest: XCTestCase { let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem) let matched = try validIdentityForService( serverHostname: nil, - socketAddress: try .makeAddressResolvingHost("192.168.0.1", port: 443), + socketAddress: try .init(ipAddress: "192.168.0.1", port: 443), leafCertificate: cert ) XCTAssertTrue(matched) @@ -122,7 +122,7 @@ class IdentityVerificationTest: XCTestCase { func testAcceptsIpv6Address() throws { guard try ipv6Supported() else { return } - let ipv6Address = try SocketAddress.makeAddressResolvingHost("2001:db8::1", port: 443) + let ipv6Address = try SocketAddress(ipAddress: "2001:db8::1", port: 443) let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem) let matched = try validIdentityForService( @@ -137,7 +137,7 @@ class IdentityVerificationTest: XCTestCase { let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem) let matched = try validIdentityForService( serverHostname: nil, - socketAddress: try .makeAddressResolvingHost("192.168.0.2", port: 443), + socketAddress: try .init(ipAddress: "192.168.0.2", port: 443), leafCertificate: cert ) XCTAssertFalse(matched) @@ -145,7 +145,7 @@ class IdentityVerificationTest: XCTestCase { func testRejectsIncorrectIpv6Address() throws { guard try ipv6Supported() else { return } - let ipv6Address = try SocketAddress.makeAddressResolvingHost("2001:db8::2", port: 443) + let ipv6Address = try SocketAddress(ipAddress: "2001:db8::2", port: 443) let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem) let matched = try validIdentityForService( diff --git a/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift b/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift index 5c8ac92b..14adcff6 100644 --- a/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift +++ b/Tests/NIOSSLTests/NIOSSLIntegrationTest.swift @@ -433,8 +433,8 @@ internal func serverTLSChannel( ) } -typealias SendableAdditionalPeerCertificateVerificationCallback = @Sendable (NIOSSLCertificate, Channel) -> - EventLoopFuture +typealias SendableAdditionalPeerCertificateVerificationCallback = + @Sendable (NIOSSLCertificate, Channel) -> EventLoopFuture internal func clientTLSChannel( context: NIOSSLContext, @@ -477,7 +477,8 @@ private struct DeprecatedTLSProviderForTests + verificationCallback: + @escaping @Sendable (NIOSSLVerificationResult, NIOSSLCertificate) -> NIOSSLVerificationResult ) { self.context = context @@ -486,14 +487,14 @@ private struct DeprecatedTLSProviderForTests Bootstrap { - bootstrap.protocolHandlers { + bootstrap.protocolHandlers { [context, serverHostname, verificationCallback] in // NIOSSLClientHandler.init only throws because of `malloc` error and invalid SNI hostnames. We want to crash // on malloc error and we pre-checked the SNI hostname in `init` so that should be impossible here. [ try! NIOSSLClientHandler( - context: self.context, - serverHostname: self.serverHostname, - verificationCallback: self.verificationCallback + context: context, + serverHostname: serverHostname, + verificationCallback: verificationCallback ) ] }