Innanzitutto, inizierò con un riepilogo. Sto utilizzando un client Apache CXF per comunicare su SSL con un fornitore di servizi Apache CXF che utilizza un certificato autofirmato. Ho importato il certificato nel truststore WebSphere sul server client, ma ricevo comunque un'eccezione "javax.net.ssl.SSLHandshakeException: SSLHandshakeException che invoca l'errore https://somesvcprovider.com/appname/svc/myservice: com.ibm.jsse2.util.h: nessun certificato attendibile".Come impostare il client Apache CXF per utilizzare il truststore WebSphere? (Ricezione dell'eccezione "Nessun certificato attendibile trovato")
Ora, ecco i dettagli:
Ho un client di servizi web Apache CXF che sto configurando usando primavera, e il cliente viene distribuito a un server di applicazioni WebSphere 6.1. Il client CXF comunica con un provider di servizi Apache CXF su un server WebSphere diverso. La comunicazione utilizza SSL.
Il fornitore di servizi utilizza un certificato autofirmato. Ho importato il certificato del fornitore nel truststore WebSphere sul server client attraverso la console di gestione. Ho raggiunto questo obiettivo passando al certificato SSL e alla gestione delle chiavi> Configurazioni SSL> NodeDefaultSSLSettings> Memorie chiave e certificati> NodeDefaultTrustStore> Certificati firmatario; quindi ho utilizzato lo strumento "Recupera da porta" per importare il certificato.
Tuttavia, ho ancora ricevo questo errore quando si tenta di contattare il fornitore del servizio: "javax.net.ssl.SSLHandshakeException: SSLHandshakeException invocando https://somesvcprovider.com/appname/svc/myservice: com.ibm.jsse2.util.h: certificato n fidato trovato".
Il file di configurazione della sorgente è il seguente:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<http:conduit name="*.http-conduit">
<!-- deactivate HTTPS url hostname verification (localhost, etc) -->
<!-- WARNING ! disableCNcheck=true should not used in production. -->
<http:tlsClientParameters disableCNCheck="true" />
</http:conduit>
<!-- Read properties from property file(s). -->
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- The *.spring.properties files are prefixed with a system property
that is set on the WebSphere server. -->
<value>classpath:spring.${my.env}.properties</value>
</list>
</property>
</bean>
<jaxws:client id="myServiceClient"
serviceClass="com.client.stub.cxf.IMyService"
address="${my.svc.url}" />
<bean id="myReport" class="com.client.MyReportRequestor">
<property name="client" ref="myServiceClient"/>
</bean>
</beans>
Come indicato sopra, il client CXF viene iniettato tramite un setter da Spring. Il codice per contattare il servizio è al di sotto:
List<String> formNames = client.retrieveNames(formIdsList);
Inoltre, non so se questo è legato, ma nessun manager di fiducia vengono restituiti quando ho ispezionare il TLSClientParameters oggetto sul client CXF in fase di esecuzione. Il codice per fare l'ispezione è qui sotto:
// Get the trust managers for this client.
Client proxy = ClientProxy.getClient(client);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
TLSClientParameters tls = conduit.getTlsClientParameters();
TrustManager[] trustManagers = tls.getTrustManagers(); // trustManagers is null
C'è qualcos'altro che devo fare per ottenere il client Apache CXF a fidarsi del certificato auto-firmato?
Preferisco non specificare il percorso di un truststore insieme a una password nel file di configurazione.
Grazie!
Non riesco a trovare un modo per utilizzare i truststor WAS, quindi presumo che sia necessario specificare il truststore nel file di configurazione come menzionato. –
Trovo la soluzione @kjetil più fattibile, in quanto non richiede uno sviluppo personalizzato –