1

While the maven build is successful I am unable to import the dependencies to the project in IntelliJ. Below is the error its showing:

Could not transfer artifact com.sun.activation:jakarta.activation:pom:1.2.1 from/to central (https://XXXXXXXXXXXXXXXX/XXXXXX/XXXXXXXXXXXXXXX): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

LowCool
  • 1,187
  • 5
  • 25
  • 51
  • may be this can help? https://stackoverflow.com/questions/6908948/java-sun-security-provider-certpath-suncertpathbuilderexception-unable-to-find – LowCool Jan 24 '23 at 10:45
  • @LowCool Thank you but I have already gone through it. I don't have any libraries imported yet that looks like while the server is up he/she is facing it. My situation is I have just cloned the project and no dependency is present because it fails at the very beginning while it imports. – Nikita Dixit Jan 24 '23 at 11:10

1 Answers1

0

The server XXXXXXXXXXXXXXXX that you are collecting dependencies from has a self signed certificate so SSL comms cannot be established.

The server certificate needs to be added to java CACERTS. That way your maven will 'trust' the server and allow SSL.

To get the cert from XXXXXXXXXXXXXXXX you do this

You can add the cert to CACERTS with java keytool as follows: (assuming your java is at D:\Java and your cert is in a file called repo.cer

"D:\Java\bin\keytool.exe" -import -alias repo -keystore  "D:\Java\jre\lib\security\cacerts" -storepass changeit -file repo.cer

Trust this certificate? [no]: answer is y

Success is indicated with: "Certificate was added to keystore"

Then set this JDK in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for importer in IDE.

Andrey
  • 15,144
  • 25
  • 91
  • 187
John Williams
  • 4,252
  • 2
  • 9
  • 18