I'm using JSOUP to connect to a web page and get some content via web scraping method. Everything seems to work fine for months but recently this error started to appear.
ERROR: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I've added the certificate of the web page (downloaded the certificate from chrome explorer, base64 cer) and added to my java cacert using this command
keytool -import -alias certificatebase64-2 -keystore "C:\Program Files\Java\jdk-11.0.10\lib\security\cacerts" -file certificate-base64.cer
I've also installed the certificate in my windows machine, since in this machine is where the java app is running, using certificate windows assistant right click on the certificate -> install certificate -> local machine -> and manually select "Trusted Root Certification Authorities"
After this two steps the app begin to works fine again, but after some hours the error pops up again.
The work around I've found is the execute the same comands explained above to add the certificate to my cacerts again (have to change the name of the import)
Here is how I connect to the web page using JSOUP
Connection.Response response = Jsoup.connect("https://www.test.store/us/").method(Connection.Method.GET)
.execute();
I can't seem to find to root cause of this error and why It fails to work some hours after I import the certificates again.