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

Add support for the TLS registry to the WebSocket-Next client extension #41004

Closed
cescoffier opened this issue Jun 6, 2024 · 0 comments · Fixed by #41095
Closed

Add support for the TLS registry to the WebSocket-Next client extension #41004

cescoffier opened this issue Jun 6, 2024 · 0 comments · Fixed by #41095
Assignees
Milestone

Comments

@cescoffier
Copy link
Member

Description

With the integrated TLS registry, it should be possible to configure the WebSocket Next client using the TLS registry instead of the specific configuration.

Implementation ideas

This is the code used for the mailer:

 private void configureTLS(String name, MailerRuntimeConfig config, TlsConfigurationRegistry tlsRegistry, MailConfig cfg,
            boolean globalTrustAll) {
        TlsConfiguration configuration = null;

        // Check if we have a named TLS configuration or a default configuration:
        if (config.tlsConfigurationName.isPresent()) {
            Optional<TlsConfiguration> maybeConfiguration = tlsRegistry.get(config.tlsConfigurationName.get());
            if (!maybeConfiguration.isPresent()) {
                throw new IllegalStateException("Unable to find the TLS configuration "
                        + config.tlsConfigurationName.get() + " for the mailer " + name + ".");
            }
            configuration = maybeConfiguration.get();
        } else if (tlsRegistry.getDefault().isPresent() && tlsRegistry.getDefault().get().isTlsEnabled()) {
            configuration = tlsRegistry.getDefault().get();
        }

       // Apply the configuration
        if (configuration != null) {
            // This part is often the same (or close) for every Vert.x client:
            cfg.setSsl(true);

            if (configuration.getTrustStoreOptions() != null) {
                cfg.setTrustOptions(configuration.getTrustStoreOptions());
            }

           // For mTLS:
            if (configuration.getKeyStoreOptions() != null) {
                cfg.setKeyCertOptions(configuration.getKeyStoreOptions());
            }

            if (configuration.isTrustAll()) {
                cfg.setTrustAll(true);
            }
            if (configuration.getHostnameVerificationAlgorithm().isPresent()) {
               // ACHTUNG HERE - this is protocol specific. The HTTP-based protocols should use HTTPS by default. 
                cfg.setHostnameVerificationAlgorithm(configuration.getHostnameVerificationAlgorithm().get());
            }

            SSLOptions sslOptions = configuration.getSSLOptions();
            if (sslOptions != null) {
                cfg.setSslHandshakeTimeout(sslOptions.getSslHandshakeTimeout());
                cfg.setSslHandshakeTimeoutUnit(sslOptions.getSslHandshakeTimeoutUnit());
                for (String suite : sslOptions.getEnabledCipherSuites()) {
                    cfg.addEnabledCipherSuite(suite);
                }
                for (Buffer buffer : sslOptions.getCrlValues()) {
                    cfg.addCrlValue(buffer);
                }
                cfg.setEnabledSecureTransportProtocols(sslOptions.getEnabledSecureTransportProtocols());

            }

        } else {
           // Mailer specific configuration (very incomplete as you can see:
            boolean trustAll = config.trustAll.isPresent() ? config.trustAll.get() : globalTrustAll;
            cfg.setSsl(config.ssl);
            cfg.setTrustAll(trustAll);
            applyTruststore(config, cfg);
        }
    }
@cescoffier cescoffier added area/housekeeping Issue type for generalized tasks not related to bugs or enhancements area/websockets and removed area/housekeeping Issue type for generalized tasks not related to bugs or enhancements labels Jun 6, 2024
@cescoffier cescoffier changed the title Add support for the TLS registry to the WebSocket-NExt client extension Add support for the TLS registry to the WebSocket-Next client extension Jun 6, 2024
geoand added a commit to geoand/quarkus that referenced this issue Jun 10, 2024
geoand added a commit to geoand/quarkus that referenced this issue Jun 10, 2024
geoand added a commit to geoand/quarkus that referenced this issue Jun 11, 2024
@cescoffier cescoffier moved this from Todo to In Progress in WG - Enhanced TLS support Jun 11, 2024
@cescoffier cescoffier assigned cescoffier, geoand and mkouba and unassigned cescoffier Jun 11, 2024
geoand added a commit to geoand/quarkus that referenced this issue Jun 11, 2024
@mkouba mkouba moved this from Todo to In Progress in WG - WebSocket Next Jun 11, 2024
geoand added a commit to geoand/quarkus that referenced this issue Jun 11, 2024
geoand added a commit that referenced this issue Jun 11, 2024
Add TLS Registry configuration to WebSockets Next Client
@github-project-automation github-project-automation bot moved this from In Progress to Done in WG - Enhanced TLS support Jun 11, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in WG - WebSocket Next Jun 11, 2024
@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone Jun 11, 2024
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants