I have a Spring Boot rest service that would call another web service (written in .NET) but it requires a public certificate of that server where the web service is installed.
I am getting the following error:
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://domain.sample.com/api/message.asmx": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Process finished with exit code -1
Not sure if you can call .asmx web service using RestTemplate though but this is my code:
RestTemplate restTemplate = new RestTemplate();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_XML);
HttpEntity<String> entity = new HttpEntity<>(rawDeviceMessage, httpHeaders);
ResponseEntity<String> resultEntity = restTemplate.postForEntity("https://domain.sample.com/api/message.asmx", entity, String.class);