-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
TlsAcceptor handling multiple domains/identity #163
Comments
This would involve adding a callback that can inspect the SNI value provided by the client and swapping the acceptor's identity out. The OpenSSL backend can do this, but I'm not sure about the others. schannel may require some feature work? |
Ah, ok, I think I'm getting it now a bit more. I'd have to get the server name using
So unless a SwapContext is already defined somewhere... It seems like the only thing required is to build a SslContext based on the keys I want. Define a callback using SSL_CTX_set_tlsext_servername_callback (named a bit differently in the openssl crate) Some of it can be simplified... I'd say that calling SSL_CTX_get_verify_callback is probably useless here unless there is some weird internal that requires to get the callback at least once to make things works... Here as long as result is But apparently the method to set the callback is only available at build time... rust-native-tls/src/imp/openssl.rs Lines 306 to 316 in 16ae466
Except this code prevent the builder from setting the callback for the TlsAcceptor as it dirrectly build the acceptor. In fact, the And I can't redefine the BuilderMethod because some fields are private like builder.identity... So it's not an easy fix until there's an API for it... Or I could probably just fallback to use OpenSSL directly. |
To expose this in native-tls, it will need to work on all three backends, not just OpenSSL. If you want to use OpenSSL directly, this is possible already. You set a servername callback which looks at the SNI field sent by the client with servername and then updates to the correct context for that domain with set_ssl_context. |
Ah yess. Finally got it to work! I'm using tokio-openssl instead of tokio-tls in the meantime.
Then use it with
The API for tokio-openssl doesn't seem to be in line with tokio-tls and other *Acceptor strucs...
But the accept method doesn't return an awaitable object like in the other libraries you made. Currently I'm only storing it in a hashmap but a more efficient method of storing them could be used. Technically it should be possible to generate certificates on the fly and eventually use ACME to generate the certificates through challenges and add the certificates to some kind of certificate storage. |
How does one generate handshake for multiple DNS?
I'm trying to make add tls support for a proxy server. The problem I have now is that even though I can get a TlsAcceptor to work based on the examples. I'm not so sure to understand how to get it to validate a provide different certificates for different HostName.
Do I have to create an Acceptor for each domain I try to validate and then check against all of the identities until I found one that Accept the connection? Or is the Acceptor handling that itself using the PKCS12 file?
The text was updated successfully, but these errors were encountered: