I am running a Java 11 SDK program through IntelliJ IDEA (on Widows 10) which is using the Java 11 Httpclient to send a simple GET request to a site that has a self-signed certificate.
final HttpClient httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(url))
.GET()
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
This was initially resulting in a "pkix path building failed" error, which I solved by adding the site's certificate to the local truststore C:\Users\[username]\.jdks\azul-11.0.16.1\lib\security\cacerts
Problem solved. Except now I need to reproduce that issue again, so I went to remove that certificate from the cacerts file and restarted the whole PC for good measure.
However, even with the certificate removed from cacerts, there are no errors and the request is still going through as if the certificate was still trusted. I thought any possible caching might be eliminated by restarting the machine.
I am out of ideas and problems with removing a previously added certificate is not a very hot topic for googling. What could be going on here that I'm missing?