code: public static SslContext forKeystoreAndTruststore(InputStream keystore, String keystorePassword, InputStream truststore, String truststorePassword, String keyManagerAlgorithm)
              throws SecurityContextException {
          try {
              final KeyStore ks = KeyStore.getInstance(KEYSTORE_JKS);
              final KeyStore ts = KeyStore.getInstance(KEYSTORE_JKS);
  
              final KeyManagerFactory keystoreKmf = KeyManagerFactory.getInstance(keyManagerAlgorithm);
              final TrustManagerFactory truststoreKmf = TrustManagerFactory.getInstance(keyManagerAlgorithm);
  
              ks.load(keystore, keystorePassword.toCharArray());
              ts.load(truststore, truststorePassword.toCharArray());
  
              keystoreKmf.init(ks, keystorePassword.toCharArray());
              truststoreKmf.init(ts);
  
              SslContextBuilder ctxBuilder = SslContextBuilder.forClient().keyManager(keystoreKmf);
              ctxBuilder.trustManager(truststoreKmf);
  
              return ctxBuilder.build();
          } catch (Exception e) {
              throw new SecurityContextException(e);
          }
      }
docs: Builds SslContext using protected keystore and truststores, overriding default key manger algorithm. Adequate for mutual TLS connections.
  @param keystore Keystore inputstream (file, binaries, etc)
  @param keystorePassword Password for protected keystore file
  @param truststore Truststore inputstream (file, binaries, etc)
  @param truststorePassword Password for protected truststore file
  @param keyManagerAlgorithm Algorithm for keyManager used to process keystorefile
  @return SslContext ready to use
  @throws SecurityContextException