Java, Semeru Runtimes and Runtimes for Business

 View Only
Expand all | Collapse all

KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

  • 1.  KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Mon December 16, 2024 08:11 AM

    I have four personal certificates upload into NodeDefaultKeyStore

    When I establish a connection with a web service, in Oracle Java, the next properties are used to specify which certificate I want to use.

                System.setProperty("javax.net.ssl.keyStore", "file.pfx");
                System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
                System.setProperty("javax.net.ssl.keyStorePassword", "password");

    However, in IBM Java, these properties are ignored, and it directly uses the NodeDefaultKeyStore, always utilizing the first loaded certificate, but I want select one of them.

    I try to use the properties

                System.setProperty("com.ibm.ssl.keyStore", "file.pfx");
                System.setProperty("com.ibm.ssl.keyStoreType", "PKCS12" );
                System.setProperty("com.ibm.ssl.keyStorePassword", "password" );

    Any idiea about this issue?

    best regards



    ------------------------------
    Jose Luis Nebril
    ------------------------------


  • 2.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Mon December 16, 2024 09:14 AM

    Those properties are specifying a file, not a certificate within a file. So, you're wanting to use an external file, not the NodeDefaultKeyStore, correct? 



    ------------------------------
    Doug Breaux
    Software Engineer
    Kyndryl
    ------------------------------



  • 3.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Mon December 16, 2024 10:05 AM
    yes.I would like use an external file pfx

    --
    Jose Luis Nebril
     
    Tfno   : +34 916-301-112
    Móvil : +34 629-167-356
    SunriseHS (Software ERP en Cloud)
    Av Dos Castillas 33 Edif IV
    28224 Pozuelo (MADRID)
     
    www.sunrisehs.com
    "La información contenida en este mensaje y/o archivo(s) es confidencial/privilegiada y está destinada a ser leída sólo por la(s) persona(s) a la(s) que va dirigida. Si usted lee este mensaje y no es el destinatario señalado, el empleado o el agente responsable de entregar el mensaje al destinatario, o ha recibido esta comunicación por error, le informamos que está totalmente prohibida, y puede ser ilegal, cualquier divulgación, distribución o reproducción de esta comunicación, y le rogamos que nos lo notifique inmediatamente y nos devuelva el mensaje original a la dirección arriba mencionada. Gracias"





  • 4.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Fri December 27, 2024 08:01 AM

    Hi Doug

    I'm soerry, but I can not find a solucion to this problem.

    We need to be able to select a specific certificate among the three certificates loaded  in the nodedefaultkeystore.

    We exec three times SOAP connextion to https://www.agenciatributaria.com but in each connexion we need use a different client pfx certificate.

    Could you help us?

    JL



    ------------------------------
    Jose Luis Nebril
    ------------------------------



  • 5.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Thu January 02, 2025 09:10 AM

    First, let's be clear that NodeDefaultKeyStore is not an external certificate file, it's a single keystore file that can contain multiple certificates in it. Perhaps you both imported these certificates into that file and have them still in external files to try to reference, but those are duplicates.

    Also, I only recognize the term "NodeDefaultKeyStore" in the context of WebSphere Application Server. Which your URL seems to confirm, but I want to be sure.

    Next, then, you have a few approaches you could use. Note that using System properties is setting things for the entire JVM, which is probably not what you want unless each execution of this call is from a separate JVM instance. That is, a new run of a standalone Java application, not, say, multiple requests within a web application. And might well not work at all if you're trying to change it for a middleware product globally (like a WebSphere server).

    If this is indeed a WebSphere application, the simplest and cleanest approach, IMO, is to use "Dynamic outbound endpoint SSL configurations", under "Security" > "SSL certificate and key management". Here, you can specify particular certificates (aliases) from a key store to use for particular hosts. 

    If this isn't for WebSphere, we can discuss other approaches.



    ------------------------------
    Doug Breaux
    Software Engineer
    Kyndryl
    ------------------------------



  • 6.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Thu January 09, 2025 01:38 PM

    Hmmm, I see @Brian S Paskin was sending you down the same path in https://community.ibm.com/community/user/wasdevops/discussion/java-developement-ssl-with-client-certificate-pfxp12 

    It looks like your complication is wanting to use multiple different client certs to the same server?

    If so, I wonder if defining multiple SSL configurations and referencing them by name in your code would work. I admit this is something I've not done before, though. 



    ------------------------------
    Doug Breaux
    Software Engineer
    Kyndryl
    ------------------------------



  • 7.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Fri January 10, 2025 01:57 PM

    Thanks Doug

    That's exactly what I'm trying to do.

    I have tried creating different SSL configurations through the WebSphere console using SSL Certificate and Key Management > SSL Configurations.
    In each configuration, I specify a keystore and a truststore that I previously created.

    Then, to try to use each of them, I used the system property com.ibm.ssl.context, but it doesn't seem to work because it keeps using NodeDefaultSSLSettings.

    Any suggestions?



    ------------------------------
    Jose Luis Nebril
    ------------------------------



  • 8.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Fri January 10, 2025 02:25 PM
    Edited by Doug Breaux Fri January 10, 2025 02:26 PM

    I'm not surprised that trying to set it JVM-wide, which is what System property is doing, doesn't work. Instead, look down this path:

    https://www.ibm.com/docs/en/was/8.5.5?topic=ascdoprse-programmatically-specifying-outbound-ssl-configuration-using-jssehelper-api-2 



    ------------------------------
    Doug Breaux
    Software Engineer
    Kyndryl
    ------------------------------



  • 9.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Sun January 12, 2025 04:03 AM

    Sorry, Doug, for responding on a Sunday.

    Wow, It works fine

    The link you sent me has solved the problem.

    I'm attaching the code that was needed to make it work, because a property was missing "com.ibm.ssl.alias"

          import com.ibm.websphere.ssl.JSSEHelper;

           ....

           JSSEHelper jsseHelper  = JSSEHelper.getInstance();    
            try {

               System.out.println("Set SSLProps like JAVA." );
               Properties sslProps = new Properties();
               sslProps.setProperty("com.ibm.ssl.trustStore", CaCertsFileName );
               sslProps.setProperty("com.ibm.ssl.trustStorePassword", "password" );
               sslProps.setProperty("com.ibm.ssl.trustStoreType", "JKS" );
               sslProps.setProperty("com.ibm.ssl.keyStore", PfxFileName );
               sslProps.setProperty("com.ibm.ssl.keyStoreType", "PKCS12" );
               sslProps.setProperty("com.ibm.ssl.keyStorePassword", PfxPwd );
               sslProps.setProperty("com.ibm.ssl.alias", Empresa.toLowerCase() );
               jsseHelper.setSSLPropertiesOnThread(sslProps);
               System.out.println("Set SSLProps to JSSHelper." );
               PrintProperties ( Empresa, sslProps );
               
            }
            catch ( Exception e) {
                 e.printStackTrace();   
            }         

    You're very welcome, Doug! If I can help you with these topics at any time, count on me.

    JL



    ------------------------------
    Jose Luis Nebril
    ------------------------------



  • 10.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Mon January 13, 2025 08:52 AM

    Glad you got it working!

    I want to explicitly note that, in addition to adding the alias property, you're also using a separate Properties object rather than System.properties. Again, I suspect this was also part of the earlier problems.



    ------------------------------
    Doug Breaux
    Software Engineer
    Kyndryl
    ------------------------------



  • 11.  RE: KEYSTORE AND JAVA IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit vs JAVA ORACLE

    Posted Mon January 13, 2025 10:25 AM

    Hi Doug

    I understand what you mean: if we use the properties provided in jssHelper, we should not use those from system.

    JL



    ------------------------------
    Jose Luis Nebril
    ------------------------------