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

Let user to provide own KeyManager and TrustManager for HTTPS server #27481

Closed
tsaarni opened this issue Aug 24, 2022 · 5 comments · Fixed by #27682
Closed

Let user to provide own KeyManager and TrustManager for HTTPS server #27481

tsaarni opened this issue Aug 24, 2022 · 5 comments · Fixed by #27682
Labels
area/vertx kind/enhancement New feature or request
Milestone

Comments

@tsaarni
Copy link
Contributor

tsaarni commented Aug 24, 2022

Description

Let user provide their own custom KeyManager and TrustManager, which would be used for the HTTPS server (by Vert.x).

This could allow implementing certificate hot-reload #15926 in the application side.

Implementation ideas

No response

@sberyozkin
Copy link
Member

@dmlloyd Hi David, I recall you were looking at some options awhile back, to provide custom factories dealing with SSL ? Sorry if it was not related

@tsaarni
Copy link
Contributor Author

tsaarni commented Aug 30, 2022

I found interesting PR #26767 that @cescoffier has kindly contributed quite recently. I'm testing this with Quarkus 2.12.0.CR1. It works very nicely even for setting own keymanager that has hot-certificate-reload capability:

@ApplicationScoped
public class VertxCustomizer implements HttpServerOptionsCustomizer {

    @Override
    public void customizeHttpsServer(HttpServerOptions options) {
        // First do whatever is required to create custom keymanager.
        ...

        // Set it to VertX HttpServerOptions
        KeyCertOptions kco = KeyCertOptions.wrap((X509KeyManager) km);
        options.setKeyCertOptions(kco);
    }
}

As far as I can see, I still have to define server certificate in quarkus.http.ssl.certificate.* config options as well, since that will enable HTTPS in the first place. Otherwise I don't get callback to customizeHttpsServer(). This feels bit clumsy, as the certificate given as config option will not end up being used, due to the customization.

Is there any workaround that I could use to avoid setting the certificates in quarkus.http.ssl.certificate.* but still enable HTTPS?

@dmlloyd
Copy link
Member

dmlloyd commented Aug 31, 2022

@dmlloyd Hi David, I recall you were looking at some options awhile back, to provide custom factories dealing with SSL ? Sorry if it was not related

IIRC what I was looking at was providing a single configuration strategy for TLS. Using the Elytron APIs we can plug in handlers for customized authentication and other things, at abstraction points that are more logical than replacing the trust manager and key manager. I'd have to review whether that would in turn allow support for hot-swapping certificates, but it seems feasible at least.

@tsaarni
Copy link
Contributor Author

tsaarni commented Sep 1, 2022

Currently the HttpServerOptionsCustomizer.customizeHttpsServer() call happens only if Vert.x SSL config was created

if (sslConfig != null) {
customizer.customizeHttpsServer(sslConfig);
}

But if user does not set certificate & key or keystore in quarkus.http.ssl.certificate.* then SSL config is not created. Null is returned here in the last branch:

if (!certificates.isEmpty() && !keys.isEmpty()) {
createPemKeyCertOptions(certificates, keys, serverOptions);
} else if (keyStoreFile.isPresent()) {
KeyStoreOptions options = createKeyStoreOptions(
keyStoreFile.get(),
keyStorePassword.orElse("password"),
sslConfig.certificate.keyStoreFileType,
sslConfig.certificate.keyStoreProvider,
sslConfig.certificate.keyStoreKeyAlias,
keyStoreKeyPassword);
serverOptions.setKeyCertOptions(options);
} else {
return null;
}

That makes it impossible for the implementer of HttpServerOptionsCustomizer to customize the HTTP server by enabling SSL config :-(. It can only customize existing SSL config.

Would it be acceptable to allow HttpServerOptionsCustomizer to create SSL config? I can work with this, but would appreciate if someone could point me into the right direction with the API change.

@tsaarni
Copy link
Contributor Author

tsaarni commented Sep 2, 2022

I have submitted #27682 to allow application to set custom KeyManager without setting dummy placeholder values in quarkus.http.ssl.certificate.*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants