private SSLContext getSslContextImpl(ClickHouseSslMode sslMode, String clientCert, String clientKey, String sslRootCert, String truststorePath, String truststorePassword, String keyStoreType) throws SSLException {
        SSLContext ctx;
        try {
            ctx = SSLContext.getInstance((String) ClickHouseDefaults.SSL_PROTOCOL.getEffectiveDefaultValue());
            TrustManager[] tms = null;
            KeyManager[] kms = null;
            SecureRandom sr = null;

            if (sslMode == ClickHouseSslMode.NONE) {
                tms = new TrustManager[]{new NonValidatingTrustManager()};
                kms = new KeyManager[0];
                sr = new SecureRandom();
            } else if (sslMode == ClickHouseSslMode.STRICT) {
                if (truststorePath != null && !truststorePath.isEmpty()) {

                    try (InputStream in = ClickHouseUtils.getFileInputStream(truststorePath)) {
                        KeyStore myTrustStore = KeyStore.getInstance(keyStoreType);
                        myTrustStore.load(in, truststorePassword.toCharArray());
                        TrustManagerFactory factory = TrustManagerFactory
                                .getInstance(TrustManagerFactory.getDefaultAlgorithm());
                        factory.init(myTrustStore);
                        tms = factory.getTrustManagers();

                    }
                } else {
                    if (clientCert != null && !clientCert.isEmpty()) {
                        KeyManagerFactory factory = KeyManagerFactory
                                .getInstance(KeyManagerFactory.getDefaultAlgorithm());
                        factory.init(getKeyStore(clientCert, clientKey), null);
                        kms = factory.getKeyManagers();
                    }

                    if (sslRootCert != null && !sslRootCert.isEmpty()) {
                        TrustManagerFactory factory = TrustManagerFactory
                                .getInstance(TrustManagerFactory.getDefaultAlgorithm());
                        factory.init(getKeyStore(sslRootCert, null));
                        tms = factory.getTrustManagers();
                    }
                }

                sr = new SecureRandom();
            } else {
                throw new IllegalArgumentException(ClickHouseUtils.format("unspported ssl mode '%s'", sslMode));
            }

            ctx.init(kms, tms, sr);
        } catch (KeyManagementException | InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException
                 | CertificateException | IOException | UnrecoverableKeyException e) {
            throw new SSLException("Failed to get SSL context", e);
        }

        return ctx;
    }
An insecure {@link javax.net.ssl.TrustManager}, that don't validate the
certificate.
clickhouse-client/src/main/java/com/clickhouse/client/config/ClickHouseDefaultSslContextProvider.java