Voglio configurare il mio Primavera @MVC dell'applicazione stub primavera RestTemplate con SSL per comunicare alla REST di base https applicazione, che schierati su server Tomcat (Spring 3, Tomcat 7). Ho fatto fino ad ora i miei lavori per refer this link. Ora non ho idea di come utilizzare questi certificati generati con Spring RestTemplate, Qualcuno può avere qualche idea per favore aiutatemi. Grazie. Fino ad ora le cose che ho fatto,Come configurare primavera RestTemplate con SSL (in primavera @MVC)
// Primavera di sicurezza Configurazioni XML
<http>
<intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
<http-basic/></http>
// Configurazioni per abilitare SSL con Tomcat
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="C:\Users\Channa\.keystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS"/>
di generazione delle chiavi, certificati ecc ,
// Genera client e Tasti d di server:
F: \ jdk1.6.0_23 \ bin> keytool -genkey -keystore keystore_client -alias clientKey -dname "CN = localhost, OU = Dev, O = MyBusiness, L = Colombo, S = Westen , C = SL "
F: \ jdk1.6.0_23 \ bin> keytool -genkey -keystore keystore_server -alias serverKey -dname" CN = localhost, OU = Dev, O = MyBusiness, L = Colombo, S = Westen, C = SL"
// generare i certificati client e server:
F: \ jdk1.6.0_23 \ bin> keytool -export -alias clientKey -rfc -keystore keystore_client> client.cert F : \ Jdk1.6.0_23 \ bin> keytool -export -alias serverKey -rfc -keystore keystore_server> server.cert
// I certificati di importazione a truststore corrispondenti:
F: \ jdk1.6.0_23 \ bin> keytool -import -alias clientcert -file client.cert -keystore truststore_server F: \ jdk1.6.0_23 \ bin> keytool -import -alias serverCert -file server.cert -keystore truststore_client
// Primavera RestTemplate configurazioni
<!--Http client-->
<bean id="httpClient" class="org.apache.commons.httpclient.HttpClient">
<constructor-arg ref="httpClientParams"/>
<property name="state" ref="httpState"/>
</bean>
<!--Http state-->
<bean id="httpState" class="com.org.imc.test.stub.http.CustomHttpState">
<property name="credentials" ref="usernamePasswordCredentials"/>
</bean>
<!--User name password credentials-->
<bean id="usernamePasswordCredentials" class="org.apache.commons.httpclient.UsernamePasswordCredentials"/>
<!--Http client-->
<bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory">
<constructor-arg ref="httpClient"/>
</bean>
<!--RestTemplate-->
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg ref="httpClientFactory"/>
</bean>
// URL https per accedere a
ResponseEntity<User> rECreateUser = restTemplate.postForEntity("https://127.0.0.1:8443/skeleton-1.0/login", user, User.class);
// eccezione attualmente ho ottenuto:
org.springframework.web.client.ResourceAccessException: I/Errore O: sun.security.validator.ValidatorException: costruzione del percorso PKIX non riuscita: sun.security.provider.certpath.SunCertPathBuilderException: impossibile trovare il percorso di certificazione valido per il target richiesto; l'eccezione annidata è javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX edificio percorso non è riuscita: sun.security.provider.certpath.SunCertPathBuilderException: incapace di trovare valido percorso di certificazione al target richiesto
È possibile mantenere il CERT client a livello di application server senza dover configurare a livello di Java? – Eranda
È possibile importare il certificato in un file di archivio sicuro personalizzato, quindi specificarlo come descritto qui: http://stackoverflow.com/a/18767045/157591 oppure è possibile sperimentare con le cose descritte qui http://stackoverflow.com/a/ 6755459/157591 –