1 Reply Latest reply on Sep 5, 2014 11:21 AM by peppem

    Webservice client with ssl authetication

    peppem Newbie

      Hi,

      I need to make a webservice client from wsdl and authenticating using a keystore.

       

      I'm using netbeans + wildfly.

      For netbeans webservice client wsdl importing i used the

       

      -J-Djavax.net.ssl.keyStore=/Users/my_path/my_keystore.jks

      -J-Djavax.net.ssl.keyStore=/Users/my_path/my_cacerts.jks

      -J-Djavax.net.ssl.trustStorePassword=changeit

      -J-Djavax.net.ssl.keyStorePassword=changeit

       

      in netbeans.conf and it works (i.e. the https wsdl is imported fine by authenticating with keystores)

       

      How to set the keystore path and password in wildfly in order to get the ssl webservice working?

       

      p.s. I'm using default webservice implementation for webservice

        • 1. Re: Webservice client with ssl authetication
          peppem Newbie

          I've solved problem programmatically

           

          port = service.getMyWebservicePort();

          try {

                     

                      SSLContext sc = SSLContext.getInstance("SSLv3");

                     

                      KeyManagerFactory kmf =

                              KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );

                     

                      KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );

                      String certPath = "/my_path/keystore.jks";

                      String certPasswd = "changeit";

                      ks.load(new FileInputStream( certPath ), certPasswd.toCharArray() );

                     

                      kmf.init( ks, certPasswd.toCharArray() );

                     

                      TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());

                       KeyStore ks_ca = KeyStore.getInstance( KeyStore.getDefaultType() );

                      String certPath_ca = "/my_path/cacerts.jks";

                      String certPasswd_ca = "changeit";

                      ks_ca.load(new FileInputStream( certPath_ca ), certPasswd_ca.toCharArray() );

                      tmf.init(ks_ca);

                     

                     

                      sc.init( kmf.getKeyManagers(), tmf.getTrustManagers() , null );

                     

                      ((BindingProvider) port ).getRequestContext()

                              .put(

                                      JAXWSProperties.SSL_SOCKET_FACTORY,

                                      sc.getSocketFactory() );

          1 of 1 people found this helpful