微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SSLHandshakeException:sun.security.validator.ValidatorException:对于集成测试中的某些 URL,但在 Spring Boot 中运行

如何解决SSLHandshakeException:sun.security.validator.ValidatorException:对于集成测试中的某些 URL,但在 Spring Boot 中运行

标题,似乎是一个重复的问题。我已经浏览了许多关于此问题的问题和文章,但无法将我的问题与它们联系起来。

链接其中一些:

  1. javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException?

  2. javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException

  3. SunCertPathBuilderException: unable to find valid certification path to requested target

  4. SSL Handshake Failures

  5. javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed duplicate

  6. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find

  7. Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?

我正在用 Java 8 在 Spring Boot 中开发一个服务。我有一百多个 API,都是 REST。我需要集成测试。他们的大多数 URL 都通过了测试,除了其中一些显示此问题。连这些API都通过了,但是突然就开始失败了。有多个开发人员正在处理同一个服务。

出于测试目的,我使用 Junit 5 和内存 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'
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?