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

Example SSL / TLS Configuration for Http Clients #8

Closed
Hakky54 opened this issue Jun 2, 2020 · 3 comments
Closed

Example SSL / TLS Configuration for Http Clients #8

Hakky54 opened this issue Jun 2, 2020 · 3 comments
Assignees

Comments

@Hakky54
Copy link
Owner

Hakky54 commented Jun 2, 2020

Every http client will have a slightly different configuration for encryption/https and therefor as a developer we need to dive into their documentation to find examples, this will be unfortunately time-consuming. Some clients just only require SSLContext, others will need a SocketFactory, SSLSocketFactory, TrustManager, X509TrustManager, X509ExtendedTrustManager, KeyManager, X509KeyManager, X509ExtendedKeyManager, DefaultSSLParameters or a list of trusted certificates. I wanted to provide an overview of http clients configuration as a cheat-sheet to make our lives easier.

Below is an overview of client configuration examples with and without TLS/SSL enabled and with basic http requests. The examples are from the github project mutual-tls-ssl, which is a practical tutorial for configuring a client and a server for four scenarios:

  • No security
  • One way authentication
  • Two way authentication
  • Two way authentication with trusting the Certificate Authority

Example client configuration and example requests / Cheatsheet

All client examples use the same base ssl configuration created within the SSLConfig class

Java

Kotlin

Scala

Feel free to ask for other client examples here

@Hakky54 Hakky54 pinned this issue Jun 2, 2020
@Hakky54 Hakky54 changed the title Example ssl configuration for http clients SSL / TLS Configuration for http clients Jun 2, 2020
@Hakky54 Hakky54 changed the title SSL / TLS Configuration for http clients Example SSL / TLS Configuration for Http Clients Jun 3, 2020
@Hakky54 Hakky54 self-assigned this Jun 3, 2020
@Hakky54 Hakky54 added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Jun 3, 2020
@skarzhevskyy
Copy link

skarzhevskyy commented Dec 30, 2020

Do you think adding example using Apache CXF will add value to this already impressive list ?
https://cxf.apache.org/docs/jax-rs-client-api.html and the same for https://cxf.apache.org/docs/dynamic-clients.html
can be achieved in CXF by adding HTTPConduitConfigurer and using already documented methods
minimalistic code example

 @Override
    public void configure(String name, String address, HTTPConduit httpConduit) {
       TLSClientParameters tls = httpConduit.getTlsClientParameters();
        if (tls == null) {       tls = new TLSClientParameters();       }
        SSLFactory sslFactory = ....;
        tls.setTrustManagers(new TrustManager[] { sslFactory.getTrustManager().get() });
        tls.setHostnameVerifier(sslFactory.getHostnameVerifier());
        httpConduit.setTlsClientParameters(tls);
    }

@Hakky54
Copy link
Owner Author

Hakky54 commented Dec 31, 2020

Hi Vlad, @skarzhevskyy

Thank you for your suggestion for these two http clients. I think it will definitely add value to the list. The https://cxf.apache.org/docs/jax-rs-client-api.html looks however identical to the jersey client, see here for the example configuration and example request: Client Configuration | Example request What do you think?

Regarding the other client, https://cxf.apache.org/docs/dynamic-clients.html, feel free to open a pull request here: https://github.com/Hakky54/mutual-tls-ssl if you want to contribute or else I will try to add it 😄

@Hakky54
Copy link
Owner Author

Hakky54 commented Jan 5, 2021

I updated the list with Apache Jax-RS and Apache WebClient configuration. Thank you for the PR Vlad!

@Hakky54 Hakky54 closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants