Sample Spring Test Client for Https


Sample Test Client for https:


	public void testAuth() throws Exception {

		TestRestTemplate restTemplate = new TestRestTemplate();
		restTemplate.getRestTemplate().setRequestFactory(new HttpComponentsClientHttpRequestFactory(

		ResponseEntity httpsEntity = restTemplate.getForEntity("https://<your id>:<https port>/greeting",





Sample Socket Factory example


	private SSLConnectionSocketFactory socketFactory() throws Exception {
		char[] password = "changeit".toCharArray();		
		KeyStore truststore = KeyStore.getInstance("JKS");
		truststore.load(new ClassPathResource("truststore.jks").getInputStream(), password);
		SSLContextBuilder builder = new SSLContextBuilder();
		builder.loadKeyMaterial(truststore, password);
		builder.loadTrustMaterial(truststore, new TrustSelfSignedStrategy());
		return new SSLConnectionSocketFactory(, new NoopHostnameVerifier());


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s