首页 > 解决方案 > 如何在我的 Spring Boot 应用程序中使用 wso2 身份服务器休息服务

问题描述

我正在尝试
"https://localhost:9443/api/identity/recovery/v0.9/recover-password?type=email&notify=false"使用休息模板来使用 wso2 中的休息服务之一。但我越来越低于例外

org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:9443/api/identity/recovery/v0.9/recover-password": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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 org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:579) at com.diligent.cdd.master.services.impl.UserServiceImpl.getWSO2ResetPWDKey(UserServiceImpl.java:49) at com.diligent.cdd.master.services.impl.UserServiceImpl.resetUserPwd(UserServiceImpl.java:43) at com.diligent.cdd.master.controllers.UserController.resetUserPassword(UserController.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)

我尝试通过以下方式在我的应用程序中启用 ssl 属性,

server.ssl.key-store-type=JKS
server.ssl.key-store=classpath:wso2carbon.jks
server.ssl.key-store-password=wso2carbon
server.ssl.key-alias=wso2carbon

标签: spring-bootwso2isresttemplate

解决方案


发生这种情况是因为 WSO2 身份服务器在 SSL 握手期间需要应用程序的证书,并且信任库中缺少应用程序的证书。所以你要做的是,

  1. 将应用程序的 SSL 公共证书导入 Identity Server 的 client-truststore.jks。它位于 /repository/resources/security/ 文件夹中。
  2. 您可以使用以下命令导入客户端信任库。

keytool -importcert -alias -file -keystore ${IS_HOME}/repository/resources/security/client-truststore.jks -storepass wso2carbon -noprompt

  1. 重新启动服务器。

你可以参考这个博客。希望这能解决您的问题


推荐阅读