0

I was recently assigned a java project. I am not very familiar with Java. I have been trying to build the projects but I am having the following error:

the trustAnchors parameter must be non-empty
    at java.base/java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
    at java.base/java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
    at java.base/java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
    at java.base/sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:94)

I am confused on how to set the trustAnchors parameter. I am not sure if this is related but I can also only see the keystore certificate when I am an admin as seen in the picture linked below:

enter image description here

Thanks

  • 1
    Does this answer your question? [Error - trustAnchors parameter must be non-empty](https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty) – andrewJames May 12 '22 at 13:23
  • The [documentation of trust anchors can be found here](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/security/cert/TrustAnchor.html). `TrustAnchor` has three constructors. Which one did you choose with which parameter values? Please show your code. – howlger May 12 '22 at 13:49
  • @andrewJames I saw that link before but I am still confused on how to resolve my issue. – ParanoidAndroid May 12 '22 at 16:26
  • @howlger I didn't write the code. However, the code base works for my entire team except me....I am not sure what I did wrong during the set up. I spent a lot of time on calls with the team to no avail. :( – ParanoidAndroid May 12 '22 at 16:28
  • The [Javadoc](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/security/cert/PKIXParameters.html#setTrustAnchors%28java.util.Set%29) says: _" InvalidAlgorithmParameterException - if the specified Set is empty (trustAnchors.isEmpty() == true)"_. The method `setTrustAnchors` is called with an empty set. In your stack trace, the line before the line `Caused by: ...` refers where the method is called. Unfortunately, you didn't show that stack trace line nor the code. – howlger May 12 '22 at 23:08

1 Answers1

0

turns out that spring-boot was using a different version java. It was therefore not finding the cacert file.