Ask a Question

How to load Keystore password through code

nakulp
New Contributor

How to load Keystore password through code

I have been trying by passing  SoapUI.getSettings().setString(SSLSettings.KEYSTORE_PASSWORD, but that ain't working. It is taking KEYSTORE but not password at runtime.

4 REPLIES 4
nmrao
Champion Level 3

Looks that statement might be incomplete, not sure if that is deliberate.

 

There should the value as well.

 

And more over, settings needs to be saved. Use below statement once required settings are done.

 

SoapUI.saveSettings();


Regards,
Rao.
nakulp
New Contributor

Hi,

 

So I have done this way:

 

SoapUI.getSettings().setString(SSLSettings.KEYSTORE_PASSWORD,
"xxxxxxx");
SoapUI.getSettings().setBoolean(SSLSettings.CLIENT_AUTHENTICATION,
true);
SoapUI.saveSettings();

 

KeyStore password is correct and is passing if I run manually through SOAP UI, through automation it's throwing me below error:

 

An error occurred [Probably bad JKS password: java.io.IOException: Keystore was tampered with, or password was incorrect], see error log for details
org.apache.commons.ssl.ProbablyBadPasswordException: Probably bad JKS password: java.io.IOException: Keystore was tampered with, or password was incorrect09:45:09,494 INFO [HttpClientSupport$Helper] Updating keyStore..
09:45:09,495 INFO [HttpClientSupport$Helper] Initializing KeyStore
09:45:09,496 ERROR [SoapUI] An error occurred [Probably bad JKS password: java.io.IOException: Keystore was tampered with, or password was incorrect], see error log for details

at org.apache.commons.ssl.KeyStoreBuilder.tryJKS(KeyStoreBuilder.java:515)
at org.apache.commons.ssl.KeyStoreBuilder.parse(KeyStoreBuilder.java:374)
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:112)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:179)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:170)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:160)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:64)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:114)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.initSocketFactory(HttpClientSupport.java:301)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper$SSLSettingsListener.settingChanged(HttpClientSupport.java:256)
at com.eviware.soapui.impl.settings.XmlBeansSettingsImpl.notifySettingChanged(XmlBeansSettingsImpl.java:113)
at com.eviware.soapui.impl.settings.XmlBeansSettingsImpl.setString(XmlBeansSettingsImpl.java:107)
at com.fepoc.test.nextgen.steps.WebServiceStepDefinition.InvokeAPIMService(WebServiceStepDefinition.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:35)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:299)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberScenarioOutline.run(CucumberScenarioOutline.java:46)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

nmrao
Champion Level 3

Unless there is a problem with password, I am afraid it would complain.

You can retry with correct password.

Alternatively, create a new keystore and use correct password.


Regards,
Rao.
nakulp
New Contributor

No I don't see a problem with the password. Unfortunately that piece of code ain't working.

cancel
Showing results for 
Search instead for 
Did you mean: