--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "JUG Torino - JVM User Group Torino" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a jugtorino+...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/jugtorino/7592389b-942a-4a3b-bf18-f09a03d773b7n%40googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/jugtorino/6744a344-32a3-4116-85c9-230521a5bef8n%40googlegroups.com.
|
Truststore |
Keystore |
|
TrustStore memorizza le credenziali di altri. |
Keystore memorizza le tue credenziali, come chiavi private o certificati di identità. |
|
La configurazione di TrustStore è necessaria per la corretta connessione lato client. |
Il Keystore è necessario quando si configura la comunicazione client-server. |
|
Un TrustStore contiene i certificati dei sistemi esterni di cui ti fidi. |
Un KeyStore contiene i certificati della tua applicazione. |

Ciao Simone, ho risolto e posto il codice Java nel caso possa servire alla Community :-)
RestTemplate restTemplate = new RestTemplate();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
SSLContext sslContext = org.apache.http.ssl.SSLContextBuilder.create()
.loadKeyMaterial(ResourceUtils.getFile(pathFileKeystore), keyStorePassword.toCharArray(),
keyPassword.toCharArray())
.loadTrustMaterial(ResourceUtils.getFile(pathFileKeystore), keyStorePassword.toCharArray())
.build();
CloseableHttpClient client = HttpClients.custom().setSslcontext(sslContext).build();
requestFactory.setHttpClient(client);
restTemplate.setRequestFactory(requestFactory);
String resp = restTemplate.getForObject(urlApiProvider, String.class);
Ho fatto entrambe le prove :
1) Con il certificate server scaduto (1_cer_server_expired.jpg)
Si interrompe adesso la comunicazione con il servizio REST del server
"Certificates": [
"certificate" : {
"version" : "v3",
"serial number" : "0x ------",
"signature algorithm": "SHA256withRSA",
"issuer" : "CN=DigiCert T",
"not before" : "2021-12-21 01:00:00.000 CET",
"not after" : "2023-01-22 24:59:59.000 CET",
"subject" : "CN=TUOSITO.com ",
"subject public key" : "RSA",
"extensions" : [
{
ERROR stderr - javax.net.ssl|SEVERE|A1|Logger.java:765|Fatal (CERTIFICATE_UNKNOWN): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (
ERROR stderr - "throwable" : {
ERROR stderr - sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
2) Prova chiamata api rest server con il certificate server che scadrà nel 2023 (2_cer_server_expiry_2023.jpg)
Tralascio tutti i log ma la sostanza è che la chiamata arriva fino alla fine:
"Finished": {
"verify data": {
0000: 4E.......................................
}'}
Ricevo i dati correttamente dal server tuosito
Buona giornata :-)
In 2 ways SSL client verifies the server certificates and the server verifies the client certificates.
At the server end, there will be a Keystore which will hold the private and public certificate of the server and truststore which will hold the public certificate of client whereas, at the client end, there will be a Keystore which will hold the private and public certificate of client whereas truststore which will hold the public key of the server.
https://www.javatpoint.com/spring-boot-rest-example
https://www.lateralecloud.it/spring-boot-servizi-web-restful/
https://www.twilio.com/blog/create-rest-apis-java-spring-boot
Ovviamente in questo caso la MA è fatta nel file application.yml :
ssl:
client-auth: need
#Require the Client to Identify Itself (Two-Way TLS): client-auth: need
#The path to the keystore file. Classpath resources may also be specified, by using the classpath prefix: classpath:path/to/keystore
key-store: classpath:certificate/server_local.jks
#The password of the keystore.
key-store-password: xxxx
#The password of the key.
key-password:
xxxx
key-store-type: JKS
#The path to the truststore file. Classpath resources may also be specified, by using the classpath prefix: classpath:path/to/trust-store
trust-store: classpath:certificate/server_local.jks
#The password of the trust store
trust-store-password: xxxx
Anche in questo come vedi dalle immagini , nel file server_local.jks.jpg io stavolta sono il server ed il file client_local.jks è quello che uso con Soap UI (new Rest Project) quando eseguo la chiamata rest al mio microservizio https://localhost:x98/mioserverrest..
client_local.jks va messo in Soap ui nelle preferences -> SSL Settings -> Keystore.
La mia API Rest con spring boot funziona correttamente con la MA.
Saluti