Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting NIOSSLCustomVerificationCallback for NIOSSLServerHandler #671

Closed
toffaletti opened this issue Feb 7, 2025 · 5 comments
Closed

Comments

@toffaletti
Copy link

Background for why this is useful and when it was added to NIOSSL: apple/swift-nio-ssl#25

Currently there is no way to pass this argument when the NIOSSLServerHandler is created:

try channel.pipeline.syncOperations.addHandler(NIOSSLServerHandler(context: self.sslContext))

Relevant docs on NIOSSLServerHandler:
https://swiftinit.org/docs/swift-nio-ssl/niossl/niosslserverhandler.init(context:customverificationcallback:configuration:)

https://swiftinit.org/docs/swift-nio-ssl/niossl/niosslserverhandler#s:6NIOSSL19NIOSSLServerHandlerC7context26customVerificationCallback13configurationAcA13NIOSSLContextC_ySayAA17NIOSSLCertificateCG_7NIOCore16EventLoopPromiseVyAA24NIOSSLVerificationResultOGtcSgAA13NIOSSLHandlerC13ConfigurationVtcfc

@toffaletti
Copy link
Author

Perhaps a closure can be passed optionally in the HTTP2ChannelConfiguration or () -> NIOSSLServerHandler

public struct HTTP2ChannelConfiguration: Sendable {

Or perhaps there is some callback I could use to remove the NIOSSLServerHandler provided by HTTP2UpgradeChannel and add one I created?

@adam-fowler
Copy link
Member

This should be easy enough to add in some form. Let me have a look

@adam-fowler
Copy link
Member

adam-fowler commented Feb 11, 2025

So we have PR #673 which adds a TLSChannelConfiguration to the HTTP2 and TLS channels. This is setting the custom verification but then it never seems to get called. I don't know if you want to test this

EDIT: Got the tests working. Forgot to set certificate verification on server TLSConfiguration

@toffaletti
Copy link
Author

Awesome! I'm working on something else right now, but I'll try to test this soon.

@adam-fowler
Copy link
Member

In 2.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants