MS3Inc / camel-rest-extensions

Apache License 2.0
2 stars 1 forks source link

add generic undertow client configuration #8

Open jam01 opened 3 years ago

jam01 commented 3 years ago
    @Bean
    public SSLContextParameters builtin() throws GeneralSecurityException {
        TrustManagerFactory managerFactory = TrustManagerFactory
                .getInstance(TrustManagerFactory.getDefaultAlgorithm());
        managerFactory.init((KeyStore) null);

        TrustManagersParameters trustParams = new TrustManagersParameters();
        trustParams.setTrustManager(managerFactory.getTrustManagers()[0]);

        SSLContextParameters answer = new SSLContextParameters();
        answer.setTrustManagers(trustParams);

        return answer;
    }

    @Bean
    public UndertowComponent client(SSLContextParameters builtin) {
        UndertowComponent answer = new UndertowComponent();
        answer.setSslContextParameters(builtin);

        return answer;
    }

see: https://access.redhat.com/documentation/en-us/red_hat_amq/6.3/html/security_guide/ssl-sysprops https://gist.github.com/ravishankarhassain/51ccfbdb350f7ee57a05799655ccd94a https://camel.apache.org/manual/latest/camel-configuration-utilities.html https://stackoverflow.com/questions/19005318/implementing-x509trustmanager-passing-on-part-of-the-verification-to-existing/19005844#19005844 https://stackoverflow.com/questions/24555890/using-a-custom-truststore-in-java-as-well-as-the-default-one https://stackoverflow.com/questions/31920719/getting-the-trusted-x509certificate-for-a-java-sslsocket https://github.com/square/okhttp/blob/okhttp_4.9.x/okhttp/src/main/kotlin/okhttp3/internal/platform/Platform.kt