Andrea Cosentino created CAMEL-25964:
----------------------------------------

             Summary: camel-vertx - VertxHelper does not apply standalone 
TrustManager from SSLContextParameters
                 Key: CAMEL-25964
                 URL: https://issues.apache.org/jira/browse/CAMEL-25964
             Project: Camel
          Issue Type: Bug
          Components: camel-vertx
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.24.0, 4.22.3, 4.18.6


h3. Current behaviour

In {{org.apache.camel.component.vertx.common.VertxHelper.setupSSLOptions(...)}} 
(camel-vertx-common), Vert.x {{TCPSSLOptions}} are configured from 
{{SSLContextParameters}}.

When {{TrustManagersParameters}} is configured with a standalone 
{{TrustManager}} via {{setTrustManager(...)}} without a {{KeyStore}}, 
{{createTrustManagerFactory(...)}} returns {{null}} because no keystore is 
present.

{{VertxHelper}} then checks only whether:
{code:java}
if (sslContextParameters.getTrustManagers() != null &&
        sslContextParameters.getTrustManagers().getTrustManager() == 
TrustAllTrustManager.INSTANCE) {
    
tcpsslOptions.setTrustOptions(TrustOptions.wrap(TrustAllTrustManager.INSTANCE));
}
{code}

Any other standalone {{TrustManager}} instance (such as a custom or pinned 
trust manager) is not passed to {{tcpsslOptions.setTrustOptions(...)}}. As a 
result, {{tcpsslOptions.getTrustOptions()}} remains {{null}}, and Vert.x falls 
back to its default trust configuration.

h3. Expected behaviour

When {{TrustManagersParameters.getTrustManager()}} is configured with any 
{{TrustManager}}, {{VertxHelper}} should wrap and apply it using 
{{TrustOptions.wrap(trustManager)}}.
When no standalone {{TrustManager}} is supplied, 
{{createTrustManagerFactory(...)}} should continue to be used to configure 
{{TrustManagerFactoryOptions}} from the configured keystore.

h3. Change

* {{org.apache.camel.component.vertx.common.VertxHelper}}: Check whether 
{{sslContextParameters.getTrustManagers() != null && 
sslContextParameters.getTrustManagers().getTrustManager() != null}}. If 
present, call 
{{tcpsslOptions.setTrustOptions(TrustOptions.wrap(trustManager))}}. Otherwise, 
call {{createTrustManagerFactory(camelContext, sslContextParameters)}} as 
before.
* Add unit tests in camel-vertx-common to verify standalone {{TrustManager}} 
instances are applied to {{TCPSSLOptions}}.

h3. Tests

* Add {{VertxHelperTest}} in {{camel-vertx-common}} to test:
  - Standalone custom {{TrustManager}} is wrapped and applied.
  - {{TrustAllTrustManager.INSTANCE}} is wrapped and applied.
  - KeyStore-based {{TrustManagerFactory}} is applied when no standalone 
manager is set.
* Verify existing Vert.x component tests remain green.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to