Search code examples
javaibm-mq

ibm mq keystore location over commandline


Currently we connect to mq from our springboot application over ssl similar to article. However, as you can see this is passing the keystore as a command line argument like -Djavax.net.ssl.trustStore=trustore.jks -Djavax.net.ssl.trustStorePassword=password -Djavax.net.ssl.keyStore=keystore.jks -Djavax.net.ssl.keyStorePassword=password. Is there another way to do this i.e not pass them via command-line?


Solution

  • Sure, you can do it from within your code:

    System.setProperty("javax.net.ssl.trustStore", trustedStore);
    System.setProperty("javax.net.ssl.trustStorePassword", trustedStorePasswd);
    
    System.setProperty("javax.net.ssl.keyStore", keyStore);
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
    

    Make sure that code is before you perform the connect call.

    Note: You do not need a keystore if you are not doing mutual authentication (which most MQ applications do not do).