### Question:
PEMCertInfo implements CertInfo<HttpClientFactory.Builder> { @Override public void applyTo(HttpClientFactory.Builder builder) { if (java.security.Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { java.security.Security.addProvider(new BouncyCastleProvider()); } try ( FileInputStream clientCert = new FileInputStream(new File(clientCertPath)); FileInputStream key = new FileInputStream(new File(keyPath)); FileInputStream certificateAuthoritiies = new FileInputStream(new File(caPath)) ) { KeyStore keyStore = PemReader.loadKeyStore(clientCert, key, Optional.ofNullable(keyPassphrase)); KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, keyPassphrase.toCharArray()); KeyStore trustStore = PemReader.loadTrustStore(certificateAuthoritiies); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); builder.withSslSocketFactory(new SSLConnectionSocketFactory(sslContext)); builder.withHttpsIOSessionStrategy(new SSLIOSessionStrategy(sslContext, new NoopHostnameVerifier())); } catch (IOException | GeneralSecurityException e) { throw new ConfigurationException(configExceptionMessage, e); } } protected  PEMCertInfo(String keyPath, String keyPassphrase, String clientCertPath, String caPath); @Override void applyTo(HttpClientFactory.Builder builder); @PluginBuilderFactory static PEMCertInfo.Builder newBuilder();  }### Answer:
@Test public void paramsArePassedToConfiguredObject() { PEMCertInfo certInfo = createTestCertInfoBuilder() .withKeyPath(TEST_KEY_PATH) .withKeyPassphrase(TEST_KEY_PASSPHRASE) .withClientCertPath(TEST_CLIENT_CERT_PATH) .withCaPath(TEST_CA_PATH) .build(); HttpClientFactory.Builder httpClientFactoryBuilder = spy(createDefaultTestObjectBuilder()); certInfo.applyTo(httpClientFactoryBuilder); verify(httpClientFactoryBuilder).withHttpsIOSessionStrategy((SchemeIOSessionStrategy) notNull()); Assert.assertNotNull(httpClientFactoryBuilder.build().httpIOSessionStrategy); }
@Test public void builderThrowsIfCantReadKey() { PEMCertInfo testCertInfo = createTestCertInfoBuilder() .withKeyPath(TEST_KEY_PATH_WITH_PASSPHRASE) .withKeyPassphrase("") .build(); expectedException.expect(ConfigurationException.class); expectedException.expectMessage(PEMCertInfo.configExceptionMessage); testCertInfo.applyTo(mock(HttpClientFactory.Builder.class)); }