eclipse - Getting SSLHandshakeException in java -


i ma getting ssl hand shake error in eclipse while calling https restful web service simple java stub but, can access url browser after importing client digital certificate browser shared service provider. hiding end point url security purpose. please me, new consuming https web services java clients.

java stub below:

 try {           url url = new url("https://*********************");              conn = (httpurlconnection) url.openconnection();             conn.setrequestmethod("get");             conn.setrequestproperty("enctype","multipart/form-data");             conn.setrequestproperty("accept", "text/xml");             system.out.println("printing connetion object "+conn);         if (conn.getresponsecode() != 200) {             throw new runtimeexception("failed : http error code : "                     + conn.getresponsecode());         }          bufferedreader br = new bufferedreader(new inputstreamreader(             (conn.getinputstream())));          string output;         system.out.println("output server .... \n");         while ((output = br.readline()) != null) {             system.out.println(output);         }         conn.disconnect();       } catch (malformedurlexception e) {           system.out.println("malformedurlexception-->"+conn);         e.printstacktrace();       } catch (ioexception e) {           system.out.println("ioexception-->"+conn);         e.printstacktrace();        } 

getting error below:

javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure     @ com.sun.net.ssl.internal.ssl.alerts.getsslexception(alerts.java:174)     @ com.sun.net.ssl.internal.ssl.alerts.getsslexception(alerts.java:136)     @ com.sun.net.ssl.internal.ssl.sslsocketimpl.recvalert(sslsocketimpl.java:1720)     @ com.sun.net.ssl.internal.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:954)     @ com.sun.net.ssl.internal.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1138)     @ com.sun.net.ssl.internal.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1165)     @ com.sun.net.ssl.internal.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1149)     @ sun.net.www.protocol.https.httpsclient.afterconnect(httpsclient.java:434)     @ sun.net.www.protocol.https.abstractdelegatehttpsurlconnection.connect(abstractdelegatehttpsurlconnection.java:166)     @ sun.net.www.protocol.http.httpurlconnection.getinputstream(httpurlconnection.java:1172)     @ java.net.httpurlconnection.getresponsecode(httpurlconnection.java:379)     @ sun.net.www.protocol.https.httpsurlconnectionimpl.getresponsecode(httpsurlconnectionimpl.java:318) 

if importing keystore not resolving issue.. not able resolve it. add following line of code. worked me.

system.setproperty( "javax.net.ssl.keystore", "d:\\g2b.p12" );  // path .p12 file           system.setproperty( "javax.net.ssl.keystorepassword", "****" );  // password of p12 file           system.setproperty( "javax.net.ssl.keystoretype", "pkcs12" );  // default jks, we're using pkcs12 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -