sslhandshakeexception:sun.security.validator.validatorexception:用于集成测试中的某些url,但在spring boot中运行

bjg7j2ky  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(243)

从标题来看,这似乎是一个重复的问题。我已经阅读了许多关于这个问题的问题和文章,但无法将我的问题与它们联系起来。
链接其中一些:
javax.net.ssl.sslhandshakeexception:sun.security.validator.validatorexception?
javax.net.ssl.sslhandshakeexception:sun.security.validator.validatorexception
suncertpathbuilderexception:找不到请求目标的有效证书路径
ssl握手失败
javax.net.ssl.sslhandshakeexception:sun.security.validator.validatorexception:pkix路径生成失败重复
sun.security.validator.validatorexception:pkix路径生成失败:sun.security.provider.certpath.suncertpathbuilderexception:无法找到
解析javax.net.ssl.sslhandshakeexception:sun.security.validator.validatorexception:pkix路径生成失败错误?
我正在用Java8在SpringBoot中开发一个服务。我有上百个api,都是rest。我需要进行集成测试。他们中的大多数人的url都通过了测试,除了一些人出现了这个问题。甚至这些api也被通过了,但突然它开始失败。有多个开发人员正在同一个服务中工作。
出于测试目的,我使用JUnit5和内存h2数据库。gradle作为构建工具。当我运行应用程序时,它工作正常。
我不明白为什么它只显示一些工作api的错误。
完整堆栈跟踪:

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 {
  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'
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题