You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow the peer's validated certificate chain to be returned in the custom verification handler (#553)
Motivation:
Users are currently able to register a custom callback in
`NIOSSLClientHandler` and `NIOSSLServerHandler` for verifiying the
certificates presented by the peer. However, there is no mechanism for
storing additional metadata for future use. This change adds support for
the peer's validated certificate chain to be returned from the custom
verification callback and later be accessed from the handler.
Modifications:
- Added a new custom verification callback type
`NIOSSLCustomVerificationCallbackWithMetadata`.
- This type is identical to the existing
`NIOSSLCustomVerificationCallback`, with the exception that callers must
complete the callback with a `NIOSSLVerificationResultWithMetadata`
(also introduced in this change). This result type can either be
initialized with no fields, or with a validated certificate chain.
- Added properties/methods to `NIOSSLHandler`, `Channel`, and
`ChannelPipeline` for accessing the validated certificate chain.
Result:
Users are now able to store the peer's validated certificate chain from
the custom verification callback and use the result downstream.
@@ -119,6 +119,10 @@ public final class NIOSSLClientHandler: NIOSSLHandler {
119
119
///
120
120
/// If set, this callback is provided the certificates presented by the peer. NIOSSL will not have pre-processed them. The callback will not be used if the
121
121
/// ``TLSConfiguration`` that was used to construct the ``NIOSSLContext`` has ``TLSConfiguration/certificateVerification`` set to ``CertificateVerification/none``.
122
+
///
123
+
/// - Note: Use ``init(context:serverHostname:customVerificationCallbackWithMetadata:)`` to provide a custom
124
+
/// verification callback where the peer's *validated* certificate chain can be returned. This data can then be
125
+
/// accessed from the handler.
122
126
publicconvenienceinit(
123
127
context:NIOSSLContext,
124
128
serverHostname:String?,
@@ -127,7 +131,39 @@ public final class NIOSSLClientHandler: NIOSSLHandler {
@@ -143,6 +179,10 @@ public final class NIOSSLClientHandler: NIOSSLHandler {
143
179
/// If set, this callback is provided the certificates presented by the peer. NIOSSL will not have pre-processed them. The callback will not be used if the
144
180
/// ``TLSConfiguration`` that was used to construct the ``NIOSSLContext`` has ``TLSConfiguration/certificateVerification`` set to ``CertificateVerification/none``.
145
181
/// - configuration: Configuration for this handler.
182
+
///
183
+
/// - Note: Use ``init(context:serverHostname:configuration:customVerificationCallbackWithMetadata:)`` to provide a
184
+
/// custom verification callback where the peer's *validated* certificate chain can be returned. This data can
185
+
/// then be accessed from the handler.
146
186
publicconvenienceinit(
147
187
context:NIOSSLContext,
148
188
serverHostname:String?,
@@ -152,7 +192,42 @@ public final class NIOSSLClientHandler: NIOSSLHandler {
@@ -59,13 +59,45 @@ public final class NIOSSLServerHandler: NIOSSLHandler {
59
59
///
60
60
/// If set, this callback is provided the certificates presented by the peer. NIOSSL will not have pre-processed them. The callback will not be used if the
61
61
/// ``TLSConfiguration`` that was used to construct the ``NIOSSLContext`` has ``TLSConfiguration/certificateVerification`` set to ``CertificateVerification/none``.
62
+
///
63
+
/// - Note: Use ``init(context:customVerificationCallbackWithMetadata:)`` to provide a custom verification
64
+
/// callback where the peer's *validated* certificate chain can be returned. This data can then be accessed from
@@ -79,14 +111,49 @@ public final class NIOSSLServerHandler: NIOSSLHandler {
79
111
/// If set, this callback is provided the certificates presented by the peer. NIOSSL will not have pre-processed them. The callback will not be used if the
80
112
/// ``TLSConfiguration`` that was used to construct the ``NIOSSLContext`` has ``TLSConfiguration/certificateVerification`` set to ``CertificateVerification/none``.
81
113
/// - configuration: Configuration for this handler.
114
+
///
115
+
/// - Note: Use ``init(context:configuration:customVerificationCallbackWithMetadata:)`` to provide a custom
116
+
/// verification callback where the peer's *validated* certificate chain can be returned. This data can then be
0 commit comments