web services - Java webservices Tomcat Jax-WS ssl, How to set up Client to authenticate certificate -


hell everyone, have set java webservices on tomcat + ssl connection link below http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat-ssl-connection/ . works fine.

my question here in code client part not authencticate certificate or ssl connection, have part check hostname,by hostname verifier,but have self-signed certificate, , not sure should do. how extend class. find few codes forum not entire idea, keystore or truststore come from. reference blog or link guide me appreciated.

my client code below

public iexample create() throws malformedurlexception{         try{             trustmanager[] trustallcerts = new trustmanager[] { new x509trustmanager() {                 public x509certificate[] getacceptedissuers() {                     return null;                 }                 public void checkclienttrusted(x509certificate[] certs, string authtype) {                     // trust                 }                  public void checkservertrusted(x509certificate[] certs, string authtype) {                     // trust                 }              } };             // install all-trusting trust manager              sc = sslcontext.getinstance("ssl");             // create empty hostnameverifier             hostnameverifier hv = new hostnameverifier() {                 public boolean verify(string hostname, sslsession arg1) {                                         if(hostname.equals(arg1.getpeerhost()) && hostname.equals("example.com"))                         {                             return true;                         }else{                              return false;                         }                     }                 };              sc.init(null,trustallcerts , new java.security.securerandom());              httpsurlconnection.setdefaultsslsocketfactory(sc.getsocketfactory());             httpsurlconnection.setdefaulthostnameverifier(hv);          }          catch(exception e){             e.printstacktrace();          }          try{             url url = new url( urlstring );              //1st argument service uri, refer wsdl document above             //2nd argument service name, refer wsdl document above                 qname qname = new qname("http://synchronization.ws/", "exampleimplclass");                  service service = service.create(url, qname);                 iexample iexample = service.getport(iexample.class);                        return iexample;                 }catch(exception e)         {             e.printstacktrace();             return null;         }     } 


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -