Your company is using a proxy to decrypt the HTTPS in between. It has a self-signed certificate. You will get this kind of Exception when sending a HTTPS request if your Java project doesn't have that self-signed certificate in its CaCerts
detailed message sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
cause 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
It should be a .cer
file.
If you don't have it, it has been installer in your PC's trusted root certificate store, you can export it (to Base64 .cer format) from there.
In IntelliJ, go to File
-> Project Structure
-> SDKs
-> JDK home path
.
Your final cacerts path should be something like this (Windows): /c/Users/your_name/.jdks/openjdk-x.y.z/lib/security/cacerts
keytool -importcert -trustcacerts -alias any_alias_name_you_want -file your_self_signed_certificate.cer -keystore your_final_jdk_cacerts_path -storepass any_password_you_want