Skip to content

Commit 8fd084b

Browse files
committed
Merge branch 'main' into add-tests
2 parents 00f2c83 + eea3f4e commit 8fd084b

File tree

11 files changed

+906
-295
lines changed

11 files changed

+906
-295
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ let package = Package(
2424
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
2525
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
2626
.package(url: "https://github.com/apple/swift-distributed-tracing.git", from: "1.0.0"),
27-
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.0.4"),
27+
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.16.0"),
2828
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
2929
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
30-
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),
30+
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.36.0"),
3131
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.30.0"),
3232
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.0.0"),
3333
],

Sources/HTTPServer/HTTPServerConfiguration.swift

Lines changed: 0 additions & 205 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import NIOCore
2+
import NIOSSL
3+
public import X509
4+
5+
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
6+
extension NIOHTTPServer {
7+
/// Connection-specific information available during request handling.
8+
///
9+
/// Provides access to data such as the peer's validated certificate chain.
10+
public struct ConnectionContext: Sendable {
11+
var peerCertificateChainFuture: EventLoopFuture<NIOSSL.ValidatedCertificateChain?>?
12+
13+
init(_ peerCertificateChainFuture: EventLoopFuture<NIOSSL.ValidatedCertificateChain?>? = nil) {
14+
self.peerCertificateChainFuture = peerCertificateChainFuture
15+
}
16+
17+
/// The peer's validated certificate chain. This returns `nil` if a custom verification callback was not set
18+
/// when configuring mTLS in the server configuration, or if the custom verification callback did not return the
19+
/// derived validated chain.
20+
public var peerCertificateChain: X509.ValidatedCertificateChain? {
21+
get async throws {
22+
if let certs = try await self.peerCertificateChainFuture?.get() {
23+
return .init(uncheckedCertificateChain: try certs.map { try Certificate($0) })
24+
}
25+
return nil
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)