Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Cineca inaugura Pitagora, il supercomputer Lenovo per la ricerca sulla fusione nucleare
Cineca inaugura Pitagora, il supercomputer Lenovo per la ricerca sulla fusione nucleare
Realizzato da Lenovo e installato presso il Cineca di Casalecchio di Reno, Pitagora offre circa 44 PFlop/s di potenza di calcolo ed è dedicato alla simulazione della fisica del plasma e allo studio dei materiali avanzati per la fusione, integrandosi nell’ecosistema del Tecnopolo di Bologna come infrastruttura strategica finanziata da EUROfusion e gestita in collaborazione con ENEA
Mova Z60 Ultra Roller Complete: pulisce bene grazie anche all'IA
Mova Z60 Ultra Roller Complete: pulisce bene grazie anche all'IA
Rullo di lavaggio dei pavimenti abbinato a un potente motore da 28.000 Pa e a bracci esterni che si estendono: queste, e molte altre, le caratteristiche tecniche di Z60 Ultra Roller Complete, l'ultimo robot di Mova che pulisce secondo le nostre preferenze oppure lasciando far tutto alla ricca logica di intelligenza artificiale integrata
Renault Twingo E-Tech Electric: che prezzo!
Renault Twingo E-Tech Electric: che prezzo!
Renault annuncia la nuova vettura compatta del segmento A, che strizza l'occhio alla tradizione del modello abbinandovi una motorizzazione completamente elettrica e caratteristiche ideali per i tragitti urbani. Renault Twingo E-Tech Electric punta su abitabilità, per una lunghezza di meno di 3,8 metri, abbinata a un prezzo di lancio senza incentivi di 20.000€
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 22-03-2010, 10:54   #1
tylerdurden83
Senior Member
 
Iscritto dal: Nov 2004
Messaggi: 691
[JAVA] JSSE e problema certificati

Ragazzi ho un problema a mettere in piedi una comunicazione client-server via socket cifrate.

Questi sono i passi che ho seguito (seguendo questo pdf):

1) Creazione delle chiavi private per il client e il server:
keytool -genkey -alias clientprivate -keystore client.private -storetype JKS -keyalg rsa -dname "CN=Your Name, OU=Your Organizational Unit, O=Your Organization, L=Your City, S=Your State,C=Your Country" -storepass clientpw -keypass clientpw

keytool -genkey -alias serverprivate -keystore server.private -storetype JKS -keyalg rsa -dname "CN=Your Name, OU=YourOrganizational Unit,O=Your Organization, L=Your City, S=Your State,C=Your Country" -storepass serverpw -keypass serverpw

2) Estrazione delle chiavi pubbliche:
keytool -export -alias clientprivate -keystore client.private -file temp.key -storepass clientpw
keytool -import -noprompt -alias clientpublic -keystore client.public -file temp.key -storepass public

keytool -export -alias serverprivate -keystore server.private –file temp.key -storepass serverpw
keytool -import -noprompt -alias serverpublic -keystore server.public -file temp.key -storepass public

3) Lato server gli step che ho seguito sono stati:
Codice:
// 1.Creazione SecureRandom
SecureRandom secureRandom = new SecureRandom();
secureRandom.nextInt();

// 2. Create a KeyStore object containing the remote client's public key.
// This is read from client.public.
KeyStore clientKeyStore = KeyStore.getInstance("JKS");
clientKeyStore.load(new FileInputStream("/home/rob/Sslserver/client.public"), "public".toCharArray());

// 3. Create a KeyStore object containing the server's public/private
//key pair, including its public key certificate. 
//This is read from server.private.
KeyStore serverKeyStore = KeyStore.getInstance("JKS");
serverKeyStore.load(new FileInputStream("/home/rob/Sslserver/server.private"), "serverpw".toCharArray());

// 4. Create a TrustManagerFactory from the remote client's 
//KeyStore. This is used to authenticate the remote client.
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(clientKeyStore);

//5. Create a KeyManagerFactory from the server's KeyStore. 
//This is used for encrypting and decrypting data      
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(serverKeyStore, "serverpw".toCharArray());

//6. Create an SSLContext object, using the KeyManagerFactory, 
//the TrustManagerFactory, and the SecureRandom.
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(),tmf.getTrustManagers(),secureRandom);

//7. Use the SSLContext to create an SSLServerSocketFactory.
SSLServerSocketFactory sf = sslContext.getServerSocketFactory();

//8. Use the SSLServerSocketFactory to create an SSLServerSocket, 
// which acts just like a regular ServerSocket, except that it is secure.
ss = (SSLServerSocket)sf.createServerSocket(9567);

//9. Call the accept() method of the SSLServerSocket to wait for an incoming connection.
ss.setNeedClientAuth( true );
client = (SSLSocket)ss.accept();
3) Lato client gli step che ho seguito sono stati:

Codice:
//1. Create a SecureRandom, a source of secure random numbers. 
//Secure random numbers are numbers that are random enough that 
//they will not make the encryption vulnerable to attack.
SecureRandom secureRandom = new SecureRandom();
secureRandom.nextInt();

// 2. Create a KeyStore object containing the remote server's 
//public key. This is read from server.public.
KeyStore serverKeyStore = KeyStore.getInstance("JKS");
serverKeyStore.load(new FileInputStream("E:/SSL/server.public"), "public".toCharArray());

// 3. Create a KeyStore object containing the client's public/private 
// key pair, including its public key certificate. This is read from client.private
KeyStore clientKeyStore = KeyStore.getInstance("JKS");
clientKeyStore.load(new FileInputStream("E:/SSL/client.private"), "clientpw".toCharArray());

// 4. Create a TrustManagerFactory from the remote server's KeyStore. 
// This is used to authenticate the remote server
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(serverKeyStore);

//5. Create a KeyManagerFactory from the client's KeyStore. 
//This is used for encrypting and decrypting data
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(clientKeyStore, "clientpw".toCharArray());

//6. Create an SSLContext object, using the KeyManagerFactory, 
//the TrustManagerFactory, and the SecureRandom.
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(),tmf.getTrustManagers(),secureRandom);

//7. Use the SSLContext to create an SSLSocketFactory.
SSLSocketFactory sf = sslContext.getSocketFactory();

//8. Use the SSLSocketFactory to create an SSLSocket, which acts 
//just like a regular Socket, except that it is secure.
socket =(SSLSocket)sf.createSocket("10.170.31.34",9567);
out = new PrintWriter(socket.getOutputStream(), true);
L'eccezione che prendo è la seguente:

Quote:
main, RECV TLSv1 ALERT: fatal, certificate_unknown
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1657)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:932)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:744)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at sslserver.Main.main(Main.java:55)

Ultima modifica di tylerdurden83 : 22-03-2010 alle 11:14.
tylerdurden83 è offline   Rispondi citando il messaggio o parte di esso
Old 23-03-2010, 12:57   #2
tylerdurden83
Senior Member
 
Iscritto dal: Nov 2004
Messaggi: 691
Uppino e aggiunta. Il server e client hanno le seguenti properties impostate:

-Djavax.net.debug=all
-Djavax.net.ssl.keyStore=E:/SSL/server.private
-Djavax.net.ssl.keyStorePassword=serverpw
-Djavax.net.ssl.trustStore=E:/SSL/client.public
-Djavax.net.ssl.trustStorePassword=public

-Djavax.net.debug=all
-Djavax.net.ssl.keyStore=E:/SSL/client.private
-Djavax.net.ssl.keyStorePassword=clientpw
-Djavax.net.ssl.trustStore=E:/SSL/server.public
-Djavax.net.ssl.trustStorePassword=public
tylerdurden83 è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Cineca inaugura Pitagora, il supercomputer Lenovo per la ricerca sulla fusione nucleare Cineca inaugura Pitagora, il supercomputer Lenov...
Mova Z60 Ultra Roller Complete: pulisce bene grazie anche all'IA Mova Z60 Ultra Roller Complete: pulisce bene gra...
Renault Twingo E-Tech Electric: che prezzo! Renault Twingo E-Tech Electric: che prezzo!
Il cuore digitale di F1 a Biggin Hill: l'infrastruttura Lenovo dietro la produzione media Il cuore digitale di F1 a Biggin Hill: l'infrast...
DJI Osmo Mobile 8: lo stabilizzatore per smartphone con tracking multiplo e asta telescopica DJI Osmo Mobile 8: lo stabilizzatore per smartph...
Lo compri una volta, lo giochi dove vuoi...
Qiantinuum annuncia Helios, "il com...
Samsung Galaxy S26 Ultra: una sola novit...
Google prepara Gemini 3 Pro e Nano Banan...
TVS non è solo moto e scooter: ec...
Alexa+ arriva su BMW: gli automobilisti ...
Gemini Deep Research arriva su Google Fi...
Rinvii a catena, Marvel 1943: Rise of Hy...
Xiaomi inaugura uno spazio dedicato ai f...
Rilasciate le specifiche di Bluetooth 6....
L'obiettivo che mette tutto a fuoco: la ...
Meta avrebbe raccolto fino al 10% dei ri...
NVIDIA DGX Spark e videogiochi? Una pess...
Serie Oppo Reno15 confermata: arriva il ...
UPDF 2025: l'editor PDF che fa (quasi) t...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 04:18.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v