Skip to content

Commit 4a1819a

Browse files
Drop Swift 5.10 (#559)
### Motivation: Swift 5.10 is no longer supported, we should bump the swift-tools version. ### Modifications: * Update Swift tools version to 6.0 * Correct the failing tests on macOS ### Result: Code reflects our support window.
1 parent b2b043a commit 4a1819a

10 files changed

+36
-25
lines changed

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the SwiftNIO open source project
@@ -58,10 +58,6 @@ let strictConcurrencyDevelopment = false
5858

5959
let strictConcurrencySettings: [SwiftSetting] = {
6060
var initialSettings: [SwiftSetting] = []
61-
initialSettings.append(contentsOf: [
62-
.enableUpcomingFeature("StrictConcurrency"),
63-
.enableUpcomingFeature("InferSendableFromCaptures"),
64-
])
6561

6662
if strictConcurrencyDevelopment {
6763
// -warnings-as-errors here is a workaround so that IDE-based development can

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@ SwiftNIO SSL | Minimum Swift Version
6161
`2.23.0 ..< 2.23.2` | 5.5.2
6262
`2.23.2 ..< 2.26.0` | 5.6
6363
`2.26.0 ..< 2.27.0` | 5.7
64-
`2.27.0 ...` | 5.8
64+
`2.27.0 ..< 2.29.3` | 5.8
65+
`2.29.3 ..< 2.31.0` | 5.9
66+
`2.31.0 ..< 2.35.0` | 5.10
67+
`2.35.0 ...` | 6.0

Sources/NIOSSL/NIOSSLClientHandler.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,5 +288,8 @@ public final class NIOSSLClientHandler: NIOSSLHandler {
288288
}
289289
}
290290

291+
// This conformance is technically redundant - Swift 6.2 compiler finally caught this
292+
#if compiler(<6.2)
291293
@available(*, unavailable)
292294
extension NIOSSLClientHandler: Sendable {}
295+
#endif

Sources/NIOSSL/NIOSSLServerHandler.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,8 @@ public final class NIOSSLServerHandler: NIOSSLHandler {
198198
}
199199
}
200200

201+
// This conformance is technically redundant - Swift 6.2 compiler finally caught this
202+
#if compiler(<6.2)
201203
@available(*, unavailable)
202204
extension NIOSSLServerHandler: Sendable {}
205+
#endif

Sources/NIOSSL/SSLCallbacks.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ extension NIOSSLContextConfigurationOverride {
320320
/// Within this callback, the user can create and return a new `NIOSSLContextConfigurationOverride` for the given host,
321321
/// and the delta will be applied to the current handshake configuration.
322322
///
323-
public typealias NIOSSLContextCallback = @Sendable (
324-
NIOSSLClientExtensionValues, EventLoopPromise<NIOSSLContextConfigurationOverride>
325-
) -> Void
323+
public typealias NIOSSLContextCallback =
324+
@Sendable (
325+
NIOSSLClientExtensionValues, EventLoopPromise<NIOSSLContextConfigurationOverride>
326+
) -> Void
326327

327328
/// A struct that provides helpers for working with a NIOSSLContextCallback.
328329
internal struct CustomContextManager: Sendable {

Sources/NIOSSL/SSLContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private func serverPSKCallback(
139139

140140
guard let serverCallback = parentSwiftContext.pskServerConfigurationCallback,
141141
let unwrappedIdentity = identity, // Incoming identity
142-
let strIdentity = String(validatingUTF8: unwrappedIdentity),
142+
let strIdentity = String(validatingCString: unwrappedIdentity),
143143
let outputPSK = psk // Output PSK key.
144144
else {
145145
return 0
@@ -198,7 +198,7 @@ private func clientPSKCallback(
198198
}
199199

200200
// If set, build out a hint otherwise fallback to an empty string and pass it into the client callback.
201-
let clientHint: String? = hint.flatMap({ String(validatingUTF8: $0) })
201+
let clientHint: String? = hint.flatMap({ String(validatingCString: $0) })
202202

203203
// Take the hint and pass it down to the callback to get associated PSK from callback
204204
let pskIdentity: PSKClientIdentityResponse?

Sources/NIOSSL/SwiftCrypto/NIOSSLSecureBytes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ extension NIOSSLSecureBytes {
240240
}
241241
}
242242

243+
// This conformance is technically redundant - Swift 6.2 compiler finally caught this
244+
#if compiler(<6.2)
243245
@available(*, unavailable)
244246
extension NIOSSLSecureBytes.Backing: Sendable {}
247+
#endif
245248

246249
extension NIOSSLSecureBytes.Backing {
247250
@usableFromInline

Sources/NIOSSL/UniversalBootstrapSupport.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ public struct NIOSSLClientTLSProvider<Bootstrap: NIOClientTCPBootstrapProtocol>:
123123
public init(
124124
context: NIOSSLContext,
125125
serverHostname: String?,
126-
customVerificationCallbackWithMetadata: @escaping (
127-
@Sendable ([NIOSSLCertificate], EventLoopPromise<NIOSSLVerificationResultWithMetadata>) -> Void
128-
)
126+
customVerificationCallbackWithMetadata:
127+
@escaping (
128+
@Sendable ([NIOSSLCertificate], EventLoopPromise<NIOSSLVerificationResultWithMetadata>) -> Void
129+
)
129130
) throws {
130131
try self.init(
131132
context: context,

Tests/NIOSSLTests/IdentityVerificationTest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ class IdentityVerificationTest: XCTestCase {
114114
let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem)
115115
let matched = try validIdentityForService(
116116
serverHostname: nil,
117-
socketAddress: try .makeAddressResolvingHost("192.168.0.1", port: 443),
117+
socketAddress: try .init(ipAddress: "192.168.0.1", port: 443),
118118
leafCertificate: cert
119119
)
120120
XCTAssertTrue(matched)
121121
}
122122

123123
func testAcceptsIpv6Address() throws {
124124
guard try ipv6Supported() else { return }
125-
let ipv6Address = try SocketAddress.makeAddressResolvingHost("2001:db8::1", port: 443)
125+
let ipv6Address = try SocketAddress(ipAddress: "2001:db8::1", port: 443)
126126

127127
let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem)
128128
let matched = try validIdentityForService(
@@ -137,15 +137,15 @@ class IdentityVerificationTest: XCTestCase {
137137
let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem)
138138
let matched = try validIdentityForService(
139139
serverHostname: nil,
140-
socketAddress: try .makeAddressResolvingHost("192.168.0.2", port: 443),
140+
socketAddress: try .init(ipAddress: "192.168.0.2", port: 443),
141141
leafCertificate: cert
142142
)
143143
XCTAssertFalse(matched)
144144
}
145145

146146
func testRejectsIncorrectIpv6Address() throws {
147147
guard try ipv6Supported() else { return }
148-
let ipv6Address = try SocketAddress.makeAddressResolvingHost("2001:db8::2", port: 443)
148+
let ipv6Address = try SocketAddress(ipAddress: "2001:db8::2", port: 443)
149149

150150
let cert = try NIOSSLCertificate(bytes: .init(multiSanCert.utf8), format: .pem)
151151
let matched = try validIdentityForService(

Tests/NIOSSLTests/NIOSSLIntegrationTest.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ internal func serverTLSChannel(
433433
)
434434
}
435435

436-
typealias SendableAdditionalPeerCertificateVerificationCallback = @Sendable (NIOSSLCertificate, Channel) ->
437-
EventLoopFuture<Void>
436+
typealias SendableAdditionalPeerCertificateVerificationCallback =
437+
@Sendable (NIOSSLCertificate, Channel) -> EventLoopFuture<Void>
438438

439439
internal func clientTLSChannel(
440440
context: NIOSSLContext,
@@ -477,7 +477,8 @@ private struct DeprecatedTLSProviderForTests<Bootstrap: NIOClientTCPBootstrapPro
477477
public init(
478478
context: NIOSSLContext,
479479
serverHostname: String?,
480-
verificationCallback: @escaping @Sendable (NIOSSLVerificationResult, NIOSSLCertificate) ->
480+
verificationCallback:
481+
@escaping @Sendable (NIOSSLVerificationResult, NIOSSLCertificate) ->
481482
NIOSSLVerificationResult
482483
) {
483484
self.context = context
@@ -486,14 +487,14 @@ private struct DeprecatedTLSProviderForTests<Bootstrap: NIOClientTCPBootstrapPro
486487
}
487488

488489
public func enableTLS(_ bootstrap: Bootstrap) -> Bootstrap {
489-
bootstrap.protocolHandlers {
490+
bootstrap.protocolHandlers { [context, serverHostname, verificationCallback] in
490491
// NIOSSLClientHandler.init only throws because of `malloc` error and invalid SNI hostnames. We want to crash
491492
// on malloc error and we pre-checked the SNI hostname in `init` so that should be impossible here.
492493
[
493494
try! NIOSSLClientHandler(
494-
context: self.context,
495-
serverHostname: self.serverHostname,
496-
verificationCallback: self.verificationCallback
495+
context: context,
496+
serverHostname: serverHostname,
497+
verificationCallback: verificationCallback
497498
)
498499
]
499500
}

0 commit comments

Comments
 (0)