Fork me on GitHub

Jersey Client - Example SSL Client Configuration

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import nl.altindag.ssl.SSLFactory;

public class App {

    public static void main(String[] args) throws Exception {
        SSLFactory sslFactory = SSLFactory.builder()
                .withIdentityMaterial("identity.jks", "password".toCharArray())
                .withTrustMaterial("truststore.jks", "password".toCharArray())
                .build();

        Client client = ClientBuilder.newBuilder()
                .sslContext(sslFactory.getSslContext())
                .hostnameVerifier(sslFactory.getHostnameVerifier())
                .build();
    }

}
Click here to discover all other possible configurations for the SSLFactory.