java - How to programmatically set the SSL context of a Axis client? -
in old project using client developed axis 1.4 call soap web service. web service use mutual authentication mechanism, have private certificate installed inside keystore , public key installed inside truststore.
the soap client used inside task of bpm process. can't , don't want use jvm global truststore , keystore. can't configure programmatically jvm global trustore , keystore:
// keystore system.setproperty("javax.net.ssl.keystore", filekeystore); system.setproperty("javax.net.ssl.keystorepassword", pwdkeystore); system.setproperty("javax.net.ssl.keystoretype", "pkcs12"); // truststore system.setproperty("javax.net.ssl.truststore", filetruststore); system.setproperty("javax.net.ssl.truststorepassword", pwdtruststore); system.setproperty("javax.net.ssl.truststoretype", "jks");
an approach force synchronize process on jvm properties , don't want that. moreover, there other java processes running on machine.
my question is: axis 1.4 offer api specify keystore , truststore use specific web service call?
ok, googling little i've found answer question. answer using solely axis 1.4 not possible specify different keystore/truststore each service invocation. need external library, called axistools.
the library implements particular kind of engineconfiguration
allows specify each service call keystore and/or truststore.
the following example explicative:
// setting configuration sslclientaxisengineconfig config = new sslclientaxisengineconfig(); config.setkeystore("path/to/your/keystore"); config.setkeystoretype("jks"); config.setkeystorepassword("password"); config.settruststore("path/to/your/truststore"); config.settruststoretype("jks"); config.settruststorepassword("password"); // important: without method invocation // client won't work @ config.initialize(); // calling web service url url = new url("https://localhost:8443/someservice"); webservicelocator locator = new webservicelocator (config); webservicesoap port = locator.getwebservicesoap(url); webservicesoapstub stub = (webservicesoapstub) port; stub.servicemethod();
and that's all, folks!!!
Comments
Post a Comment