By looking at the title, it may seems that it is a duplicate question. I have gone through a number of questions and article regarding this issue but unable to relate my issue with them.
Links some of them :
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException?
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
SunCertPathBuilderException: unable to find valid certification path to requested target
I am developing a service in Spring Boot with Java 8. I have more than hundred API, all are REST. I need to integration test. Most the URL of them are passing the test except some of them are showing this problem. Even these API were passed, but suddenly it started to fail. There are multiple dev is working into the same service.
For testing purpose i am using Junit 5 and in memory H2 database. Gradle as build tool. When i am running the application it is working fine.
I am not understanding why it is showing error only for some working API's.
Full Stack trace :
java.io.IOException: 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
at com.bracits.common.service.storage.MinIoFileSystem.save(MinIoFileSystem.java:77)
at com.bracits.common.service.storage.MinIoFileSystem.save(MinIoFileSystem.java:90)
at com.bracits.common.service.storage.FileSystemService.save(FileSystemService.java:27)
at com.bracits.abs.sharedentity.service.FileServiceImpl.uploadFile(FileServiceImpl.java:57)
at com.bracits.abs.sharedentity.service.FileServiceImpl.save(FileServiceImpl.java:43)
at com.bracits.abs.am.service.AfoNominationInfoServiceImpl.save(AfoNominationInfoServiceImpl.java:49)
at com.bracits.abs.am.controller.AfoNominationInfoController.createAfoNominationInfo(AfoNominationInfoController.java:51)
..................
Caused by: 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
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
............. 165 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
... 198 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 204 more
dependencies:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.oracle.database.jdbc:ojdbc8'
implementation 'com.company.abs:shared-entity:0.0.5-SNAPSHOOT'
// implementation 'org.springframework.integration:spring-integration-amqp'
// implementation 'org.springframework.integration:spring-integration-http'
// implementation 'org.springframework.integration:spring-integration-jpa'
// implementation 'org.springframework.integration:spring-integration-security'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'org.modelmapper:modelmapper:2.3.0'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.3'
implementation group: 'io.spring.javaformat', name: 'spring-javaformat-gradle-plugin', version: '0.0.25', ext: 'pom'
implementation 'com.company:common:0.0.19-SNAPSHOOT'
implementation 'org.springframework.cloud:spring-cloud-stream'
implementation 'org.springframework.cloud:spring-cloud-starter-stream-rabbit'
implementation 'com.company:notification-client-spring-boot-starter:0.0.2-SNAPSHOT'
//For Development
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// for testing
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// testImplementation 'org.springframework.amqp:spring-rabbit-test'
// testImplementation 'org.springframework.integration:spring-integration-test'
testImplementation 'org.springframework.security:spring-security-test'
}