ho risolto con questo codice:
codice:
// Key Store
MakeKeyStore objMakeKeyStore = new MakeKeyStore();
KeyStore objKeyStore = objMakeKeyStore.getKeyStore();
// Key Manager
MakeKeyManagerFactory objMakeKeyManagerFactory = new MakeKeyManagerFactory();
KeyManagerFactory objKeyManagerFactory = objMakeKeyManagerFactory.getKeyManagerFactory();
// SSLContext
SSLServer objSSLServer = new SSLServer();
// Recupero il SSLContext
SSLContext objSSLContext = objSSLServer.getSSLContext();
// Carico il Key Store
objKeyStore.load(new FileInputStream(this.pathKeyStore), this.storePass.toCharArray());
//Carico Trust Store
objKeyManagerFactory.init(objKeyStore, this.passKeySytore.toCharArray());
// Trust Store
MakeKeyStore objMakeTrustStore = new MakeKeyStore();
KeyStore objTrustStore = objMakeTrustStore.getKeyStore();
// Carico il Trust Store
objTrustStore.load(new FileInputStream(this.pathTrustStore), this.storePass.toCharArray());
// Trust Manager
MakeTrustManagerFactory objMakeTrustManagerFactory = new MakeTrustManagerFactory();
TrustManagerFactory objTrustManagerFactory = objMakeTrustManagerFactory.getTrustManagerFactory();
objTrustManagerFactory.init(objTrustStore);
// objSSLContext.init(objKeyManagerFactory.getKeyManagers(), objTrustManagerFactory.getTrustManagers(), null);
objSSLContext.init(objKeyManagerFactory.getKeyManagers(),objTrustManagerFactory.getTrustManagers(), null);
objSSLSocketFactory = objSSLContext.getSocketFactory();
/*
java.security.cert.Certificate cert = objKeyStore.getCertificate("C:\\certificate\\webtest.arag.it.crt");
System.out.println("CERT " + cert);
*/
echoSocket =(SSLSocket)objSSLSocketFactory.createSocket(this.url, this.port);
echoSocket.setSoTimeout(this.timer);
alServer = new PrintWriter(echoSocket.getOutputStream(), true);
dalServer = new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
// System.out.println("--- PRIMA DI FARE alServer.print(messaggio) ");
alServer.print(this.request);
// System.out.println("--- DOPO alServer.print(messaggio) ");
alServer.flush();
// System.out.println("--- HO FATTO ANCHE alServer.flush() ");
String line = "";
while ((line = dalServer.readLine()) != null)
{
messaggioDalServer.append(line);
messaggioDalServer.append('\n');
}
System.out.println(messaggioDalServer);
Ma non capisco perchè se facevo cosi:
char[] b = new char [2000];
dalServer.read(b);
non funzionava!..
ps. sbagliati anche password e keystore / truestore