Skip to content

ClientBuilder.trustStore() isn't respected when creating a client #37

Description

@niloc132

jakarta.ws.rs.client.ClientBuilder#trustStore isn't used in the creation process - if a server has a custom truststore that its certificate is signed by, the client will have an error when connecting.

As a workaround, the truststore can be passed to the underlying ClientConnector directly.

            final ClientConnector clientConnector = new ClientConnector();

            // Workaround, explicitly create the sslcontextfactory and pass to the connector
            SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
            sslContextFactory.setTrustStore(keyStore);
            clientConnector.setSslContextFactory(sslContextFactory);


            final ClientConnectionFactory.Info h1 = HttpClientConnectionFactory.HTTP11;
            final HTTP2Client http2Client = new HTTP2Client(clientConnector);
            final ClientConnectionFactory.Info h2 = new ClientConnectionFactoryOverHTTP2.HTTP2(http2Client);

            final HttpClientTransport transport = new HttpClientTransportDynamic(clientConnector, h2, h1);

            final HttpClient c = new HttpClient(transport);
            ClientBuilder clientBuilder =
                    ClientBuilder.newBuilder().register(new JettyClientEngine(c));

            // This will not work as of 1.0.0-alpha2
            clientBuilder = clientBuilder.trustStore(keyStore);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions