hi ,
i am roy.
am working on a client application to connect to a secure server.
i have the client certificate for the server & self signed certificate from
issuing authority who issued the certificate to the server.
i am using jdk.1.4.1_02 .
JSSE implementation comes here default.
so i have included both certificate in my cacerts file in
JAVA_HOME/jre/lib/security
/cacerts
now if i try to connect to the server using following code
--------------------------
--------my
code(1)-------------------
----------
-----
System.setProperty("java.p
rotocol.ha
ndler.pack
ages",
"com.sun.net.ssl.internal.
www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.s
sl.Provide
r());
HttpsURLConnection conn;
URL urlHost1 = new URL("
https://myurl");
conn = (HttpsURLConnection) urlHost.openConnection();
DataInputStream input;
input = new DataInputStream(conn.getIn
putStream
());
String str;
while (null != ((str = input.readLine()))) {
System.out.println(str);
}
input.close();
i get javax.net.ssl.SSLHandshake
Exception:
Received fatal alert: handshake_failure
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
---
so i again tried in different way
i craeted my own trustmanager class to allow all certificates
then i do as following
SSLSocketFactory factory;
SSLContext sslcontext = SSLContext.getInstance( "TLS");
sslcontext.init( null, // No KeyManager required
new TrustManager[] { new MyTrustManager()},
null);
factory = ( SSLSocketFactory) sslcontext.getSocketFactor
y();
// Connect to the web server.
//SSLSocket s=(SSLSocket)factory.creat
eSocket("m
y url",xxxx);
HttpsURLConnection.setDefa
ultSSLSock
etFactory(
factory);
then i again try to connect its same
handshake failure i am getting handshake failure
error
if any one help me it will be great
thanks in advance
roy