This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

the halt of keyStore.store(OutputStream,String password)


Hi , all,

I want to use the keyStore to save the certificate from server through SSL Socket(Jessie with libgcj4.2 ). But when I use
keyStore.store(OutputStream,String password) function, my application will halt for quite a while. and finnally got a exception
when communicating with the server.
Java.io.IOException
at gnu.java.net.PlainSocketImpl$SocketOutputStream.write(natPlainSocketImpl.cc:350)
at gnu.javax.net.ssl.provider.RecordOutputStream.write(RecordOutputStream.java:178)
at gnu.javax.net.ssl.provider.RecordOutputStream.write(RecordOutputStream.java:112)
at gnu.javax.net.ssl.provider.RecordOutputStream.write(RecordOutputStream.java:107)
at gnu.javax.net.ssl.provider.SSLSocket.changeCipherSpec(SSLSocket.java:1142)
at gnu.javax.net.ssl.provider.SSLSocket.doClientHandshake(SSLSocket.java:2073)
at gnu.javax.net.ssl.provider.SSLSocket.startHandshake(SSLSocket.java:521)
My code seens below : MyX509TrustManager.java :
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
// Add Chain to the keyStore.
for (int i = 0; i < chain.length; i++)
keyStore.setCertificateEntry(chain[i].getIssuerDN()
.toString(), chain[i]);
// save to the file
keyStore.store(new FileOutputStream(keyStorePath)
, keyStorePassword);
tmf.init(keyStore); //TrustManagerFactory is to be initialized again
tm = tmf.getTrustManagers()[0]; // reget the TrustManager.
}


And I removed this line : keyStore.store(new FileOutputStream(keyStorePath) , keyStorePassword), and all the things gone. My application
worked fine with the server.


I use libgcj4.2 in Linux/2.6/gnome2.14, and I don'k know why, the same code works fine in sun jdk1.6;

Thanks for your any help.

Best Regards.
Jimmy.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]