webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

SSL Certificate Creation Using Keytool Commands

webMethods Community Member

webMethods Community MemberFri December 18, 2015 05:20 AM

  • 1.  SSL Certificate Creation Using Keytool Commands

    Posted Thu August 13, 2015 07:39 AM

    keytool is available in /jvm/bin

    For Server1

    Step 1: Creating the “public-private” key pair.
    keytool -genkey -alias Server1 -validity 365 -keystore D:\Certificates\Server1_keystore.jks

    Step 2: Validate the “public-private” key pair.
    keytool -list -v -keystore D:\Certificates\Server1_keystore.jks

    Step 3: Extract the “public key” from the “public-private” key pair
    keytool -export -alias Server1 -keystore D:\Certificates\Server1_keystore.jks -rfc -file D:\Certificates\Server1_publickey.cer

    Step 4: Create the Truststore using the public key extracted.
    keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    keytool -list -v -keystore D:\Certificates\Server1_trustore.jks

    For Server2

    Step 5: Creating the “public-private” key pair.
    keytool -genkey -alias Server2 -validity 365 -keystore D:\Certificates\Server2_keystore.jks

    Step 6: Validate the “public-private” key pair.
    keytool -list -v -keystore D:\Certificates\Server2_keystore.jks

    Step 7: Extract the “public key” from the “public-private” key pair
    keytool -export -alias Server2 -keystore D:\Certificates\Server2_keystore.jks -rfc -file D:\Certificates\Server2_publickey.cer

    Step 8: Create the Truststore using the public key extracted.
    keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server2_trustore.jks
    keytool -list -v -keystore D:\Certificates\Server2_trustore.jks

    Combine

    Step 9: Add both public cert to the truststore .
    keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks
    keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    keytool -list -v -keystore D:\Certificates\Server2_trustore.jks


    #webMethods
    #Integration-Server-and-ESB
    #B2B-Integration


  • 2.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Thu December 10, 2015 10:09 AM

    I have generated certificate,public key and trust store for server1 and server2 as per the commands mention above
    BUT
    While I am trying to combine both public certs to the trust store as per the commands mention in Step 9

    Combine

    Step 9: Add both public cert to the truststore .
    keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks ( This command is working good BUT 2nd commands failing with below exception)
    keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    keytool -list -v -keystore D:\Certificates\Server2_trustore.jks

    Exception while combining both public certs to trust store? Pls explain why it’s failing or how to combine both public certs to trust store ?

    D:\webMethods\jvm\jvm\jre\bin>keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    Enter keystore password:
    keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect


    #webMethods
    #B2B-Integration
    #Integration-Server-and-ESB


  • 3.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Thu December 10, 2015 01:56 PM

    Hi Rajiv,

    make sure to use the correct password for the keystores.

    The password is the one choosen for the JKS-File.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #webMethods
    #B2B-Integration


  • 4.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Mon December 14, 2015 04:34 AM

    Hi Holger,

    WM Env : 9.7
    This is just a POC so,I kept password similar from step 1 to step 9 and even had tried on different webMethods installation directory where keytool utility is present.

    commands in step 1-8 is working fine but while executing step 9 command

    Is it full/single commands or combination of 2 commands which we have to execute individually ?

    keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks
    keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    keytool -list -v -keystore D:\Certificates\Server2_trustore.jks


    D:\webMethods\jvm\jvm\jre\bin>keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks
    Enter keystore password: → Working good but when i enter next line/commands shown below it’s failing with exception

    D:\webMethods\jvm\jvm\jre\bin>keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks
    Enter keystore password:
    keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect


    #Integration-Server-and-ESB
    #webMethods
    #B2B-Integration


  • 5.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Mon December 14, 2015 05:13 AM

    I believe step 9 :Add both public cert to the trust store was mention in initial thread was incorrect

    Correct commands Is :-

    keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks -list -v -keystore D:\Certificates\Server2_trustore.jks

    Can some one verify and confirm same? As above CMD was executed successfully


    #B2B-Integration
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Mon December 14, 2015 02:08 PM

    Hi Rajiv,

    what does “keytool -list -v -keystore D:\Certificates\Server1_trustore.jks” return instead “keytool -list -v -keystore D:\Certificates\Server2_trustore.jks”?

    What did “keytool -list -v -keystore D:\Certificates\Server2_trustore.jks” in the previous try?

    I cannot see any thing wrong with the original commands, so I guess there must have been a typo in at least one of the passwords used in the first 8 steps which causes the error message in step 9.

    Did you try to re-create the truststores and try step 9 again?.

    Must likely you will only need to create one single truststore for both certificates:
    keytool -import -trustcacerts -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Servers_trustore.jks
    keytool -import -trustcacerts -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Servers_trustore.jks
    keytool -list -v -keystore D:\Certificates\Servers_trustore.jks

    Regards,
    Holger


    #Integration-Server-and-ESB
    #B2B-Integration
    #webMethods


  • 7.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Wed December 16, 2015 06:38 AM

    Hi Holger,

    Yeah, I have tried twice but get struck while combining certs into trust store at step 9

    While I am trying to combine both certs into single trust store file by using step 9 command but no luck :frowning: Can you tell me what was the wrong in below command ?

    D:\webMethods\jvm\jvm\bin>keytool -import -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Server2_trustore.jks keytool -import -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Server1_trustore.jks keytool -list -v -keystore D:\Certificates\Server2_trustore.jks
    Illegal option: keytool
    keytool -importcert [OPTION]…

    Imports a certificate or a certificate chain

    Options:

    -noprompt do not prompt
    -trustcacerts trust certificates from cacerts
    -protected password through protected mechanism
    -alias alias name of the entry to process
    -file input file name
    -keypass key password
    -keystore keystore name
    -storepass keystore password
    -storetype keystore type
    -providername provider name
    -providerclass provider class name
    -providerarg provider argument
    -providerpath provider classpath
    -v verbose output

    Use “keytool -help” for all available commands

    D:\webMethods\jvm\jvm\bin>


    #Integration-Server-and-ESB
    #B2B-Integration
    #webMethods


  • 8.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Wed December 16, 2015 08:41 AM

    Hi Rajiv,

    the command is just to long.

    I dont think that keytool is able to handle multliple occurences of the options in one call.

    Did you try the commands from my last post?
    What was the outcome?

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #B2B-Integration


  • 9.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Thu December 17, 2015 08:15 AM

    Pls find the outcome

    D:\webMethods\jvm\jvm\bin>keytool -import -trustcacerts -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Servers_trustore.jks keytool -import -trustcacerts -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Servers_trustore.jks keytool -list -v -keystore D:\Certificates\Servers_trustore.jks
    Illegal option: keytool
    keytool -importcert [OPTION]…

    Imports a certificate or a certificate chain

    Options:

    -noprompt do not prompt
    -trustcacerts trust certificates from cacerts
    -protected password through protected mechanism
    -alias alias name of the entry to process
    -file input file name
    -keypass key password
    -keystore keystore name
    -storepass keystore password
    -storetype keystore type
    -providername provider name
    -providerclass provider class name
    -providerarg provider argument
    -providerpath provider classpath
    -v verbose output

    Use “keytool -help” for all available commands

    D:\webMethods\jvm\jvm\bin>


    #webMethods
    #Integration-Server-and-ESB
    #B2B-Integration


  • 10.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Thu December 17, 2015 08:27 AM

    Hi Rajiv,

    now I am getting the error:

    You have put all three commands into one line.
    Please try these one by one using the password of your choice.

    keytool -import -trustcacerts -alias Server1 -file D:\Certificates\Server1_publickey.cer -keystore D:\Certificates\Servers_trustore.jks
    keytool -import -trustcacerts -alias Server2 -file D:\Certificates\Server2_publickey.cer -keystore D:\Certificates\Servers_trustore.jks
    keytool -list -v -keystore D:\Certificates\Servers_trustore.jks

    Regards,
    Holger


    #Integration-Server-and-ESB
    #B2B-Integration
    #webMethods


  • 11.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Fri December 18, 2015 05:20 AM


  • 12.  RE: SSL Certificate Creation Using Keytool Commands

    Posted Fri December 18, 2015 06:01 AM

    Rajiv – I don’t have environment to help you on this certificate part. Anyways Holger hands are always helpful.

    Thanks,


    #webMethods
    #Integration-Server-and-ESB
    #B2B-Integration