gpt4 book ai didi

java - 使用 Https 和 tomcat 进行 Spring 远程处理

转载 作者:太空宇宙 更新时间:2023-11-03 14:20:32 25 4
gpt4 key购买 nike

我的应用程序是一个基于 swing 的客户端,使用 spring 远程 Http 调用程序与 tomcat 通信,我想转换为 https。

org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [https://localhost:8443/aten_server/metadataservice/MetaDataService-httpinvoker]; 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.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:212)        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:145)        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)        at $Proxy4.getMemberStatuses(Unknown Source)        at com.kantarmedia.panelmanager.presenters.AbstractPresenter.(AbstractPresenter.java:114)        at com.kantarmedia.panelmanager.presenters.MainPanelPresenter.(MainPanelPresenter.java:28)        at com.kantarmedia.panelmanager.PanelManagerFactory.(PanelManagerFactory.java:135)        at com.kantarmedia.panelmanager.PanelManagerApp.startup(PanelManagerApp.java:32)        at org.jdesktop.application.Application$1.run(Application.java:171)        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)        at java.awt.EventQueue.access$000(EventQueue.java:85)        at java.awt.EventQueue$1.run(EventQueue.java:603)        at java.awt.EventQueue$1.run(EventQueue.java:601)        at java.security.AccessController.doPrivileged(Native Method)        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)        at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)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 com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1649)        at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)        at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1206)        at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:136)        at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)        at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893)        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)        at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:502)        at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)        at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.executePostMethod(CommonsHttpInvokerRequestExecutor.java:196)        at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:130)        at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:192)        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:174)        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:142)        ... 22 moreCaused 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:323)        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:217)        at sun.security.validator.Validator.validate(Validator.java:218)        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185)        ... 44 moreCaused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318)        ... 50 more

My client side spring config file is

<bean id="memberDataServiceHttpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="#{systemProperties['aten.protocol']}://#{systemProperties['aten.host']}:#{systemProperties['aten.port']}/aten_server/memberdataservice/MemberDataService-httpinvoker"/>
<property name="serviceInterface" value="com.kantar.server.panel.services.IMemberDataService"/>
<property name="httpInvokerRequestExecutor">
<bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor" />
</property>
</bean>

请帮我解决问题

最佳答案

问题不在于 Spring Remoting,而是您正在访问的服务器上的证书不是由 CA 或可信证书签名的 - 您需要将此证书添加到您的 keystore 。

参见 Adding a foreign server's self-signed certificate to the trusted certificates of my Tomcat了解如何做到这一点。

关于java - 使用 Https 和 tomcat 进行 Spring 远程处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6911857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com