I use PFX file in postman like this but I want to use in spring boot as like postman.`
I tried:
System.setProperty("javax.net.ssl.trustStore", AccessTokenService.class.getClassLoader().getResource("security/XXX.pfx").getFile());
System.setProperty("javax.net.ssl.trustStorePassword", "XXX");
System.setProperty("javax.net.ssl.keyStore", AccessTokenService.class.getClassLoader().getResource("security/XXX.pfx").getFile());
System.setProperty("javax.net.ssl.keyStorePassword", "XXX");
and
System.setProperty("javax.net.ssl.trustStore", "C:/XX/XX.pfx");
System.setProperty("javax.net.ssl.trustStorePassword", "XXX");
System.setProperty("javax.net.ssl.keyStore", "C:/XX/XX.pfx");
System.setProperty("javax.net.ssl.keyStorePassword", "XXX");
final String allPassword = "XXX";
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = SSLContextBuilder
.create()
.loadKeyMaterial(ResourceUtils.getFile("classpath:XX.pfx"),
allPassword.toCharArray(), allPassword.toCharArray())
//.loadTrustMaterial(ResourceUtils.getFile("classpath:XX.jks"), allPassword.toCharArray())
.loadTrustMaterial(null, acceptingTrustStrategy)
.build();
HttpClient client = HttpClients.custom()
.setSSLContext(sslContext)
.build();
HttpComponentsClientHttpRequestFactory requestFactory =
new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(client);
RestTemplate restTemplate = new RestTemplate(requestFactory);
return restTemplate;
but
I/O error on GET request for "https://XX.bkm.com.tr/oauth-provider/": Connect to XX.com.tr:443 [XX.com.tr/XX.XXX.XXX.55] failed: Connection timed out: connect
I can telnet XX.XXX.XXX.55 443 and when use postman with client sertificate everytinhs successfull but when I use spring boot I am getting Connection Timed out