Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno
Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno
Con la quattordicesima generazione Lenovo ridisegna il suo ThinkPad più iconico attorno al nuovo Space Frame e ai processori Intel Core Ultra Series 3. Resta sotto 1Kg, è molto più semplice da riparare e si rivolge al professionista che lavora in mobilità, con un prezzo da prodotto di vertice.
Jabra Evolve3 85: le cuffie sia per l'intrattenimento che per il lavoro
Jabra Evolve3 85: le cuffie sia per l'intrattenimento che per il lavoro
Le Jabra Evolve3 85 non sono semplicemente cuffie Bluetooth con cancellazione del rumore. Sono un dispositivo professionale pensato per chi trascorre gran parte della giornata in riunione, al telefono o davanti a un assistente basato sull'intelligenza artificiale
MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB per far girare in locale anche i modelli più grandi
MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB per far girare in locale anche i modelli più grandi
Abbiamo provato MSI PRO MAX EDGE AI+, un mini-PC professionale progettato per eseguire modelli di intelligenza artificiale in locale, senza dipendere dal cloud. Il sistema abbina il processore AMD Ryzen AI Max+ 395, 128 GB di memoria unificata e un telaio in alluminio da appena 4 litri, con l'obiettivo di offrire capacità di elaborazione elevate in un formato compatto.
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


Lenovo ThinkPad X1 Carbon Gen 14: il business ultraleggero si rinnova dall’interno Lenovo ThinkPad X1 Carbon Gen 14: il business ul...
Jabra Evolve3 85: le cuffie sia per l'intrattenimento che per il lavoro Jabra Evolve3 85: le cuffie sia per l'intratteni...
MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB per far girare in locale anche i modelli più grandi MSI PRO MAX EDGE AI+, Ryzen AI Max+ 395 e 128 GB...
Recensione vivo X500 Pro Max: la fotografia mobile ha un nuovo protagonista Recensione vivo X500 Pro Max: la fotografia mobi...
WoW Forever: la beta è stato uno dei momenti più alti della storia dei videogiochi, e non si ripeterà WoW Forever: la beta è stato uno dei mome...
TSMC valuta la produzione di 3D DRAM su ...
Il Cybertruck ha i giorni contati? Musk ...
Meta porta la voce su Muse, e a sponsori...
Perché il disco principale di Win...
Quanta acqua consuma l'IA? Da cinque goc...
Airbnb lancerà un assistente AI per pian...
25 miliardi sul tavolo: i sauditi voglio...
TV Haier QLED da 65'' a meno di 400€ su ...
Il meglio degli sconti Amazon del weeken...
Il rumore degli aerei in sottofondo può ...
Ecco un tapis roulant pieghevole da 14 k...
Roborock Qrevo 2 Pro Set, coupon da 50€ ...
Gemini addestra l'IA con le chat private...
Addio ai floppy disk nei centri di contr...
Crolla il prezzo di Google Pixel 11 da 5...
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: 12:20.


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