App Connect

App Connect

Join this online user 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
  • 1.  HTTP API Call using Java compute node?

    Posted Mon April 07, 2025 08:56 AM

    Instead of HTTP Request node, need to use JCN for calling HTTP API. Using mqsichangeproperties gave truststore and keystore. But still I am getting SSLHandshake error: Unknown certificate. 

    Please advise.



    ------------------------------
    Rukmani Thirunavukkarasu
    ------------------------------


  • 2.  RE: HTTP API Call using Java compute node?

    Posted Tue April 08, 2025 01:34 AM

    Hi,

    I don't think a JCN can use automatically ACE's SSL profile or keystore settings.
    You must load keystores manually in code using KeyStore and SSLContext.
     
    What's the reason you can't use HTTP request node to call the api?
    mvg
    Kim


    ------------------------------
    Kim Meynendonckx
    ------------------------------



  • 3.  RE: HTTP API Call using Java compute node?

    Posted Tue April 08, 2025 01:45 AM

    Previously from JCN we used to fetch details from DB. Now DB is replacedby API. 

    So instead of introducing a new node, it was suggested if we can use JCN itself to make HTTPS API call.

    So from JCN , how to pass truststore or keystore details?



    ------------------------------
    Rukmani T
    ------------------------------



  • 4.  RE: HTTP API Call using Java compute node?

    Posted Tue April 08, 2025 02:13 AM

    Hi,

    I quickly googled and found some java examples:

    KeyStore keyStore = KeyStore.getInstance("JKS");
    try (InputStream ksIs = new FileInputStream("/path/to/keystore.jks")) {
        keyStore.load(ksIs, "keystorePassword".toCharArray());
    }
    
    KeyStore trustStore = KeyStore.getInstance("JKS");
    try (InputStream tsIs = new FileInputStream("/path/to/truststore.jks")) {
        trustStore.load(tsIs, "truststorePassword".toCharArray());
    }
    
    KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    kmf.init(keyStore, "keystorePassword".toCharArray());
    
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init(trustStore);
    
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
    
    HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());

    My advice is to just add the extra node. You can write code where you propagate to the http-request node and continue in the code with the response.

    mvg,

    Kim



    ------------------------------
    Kim Meynendonckx
    ------------------------------



  • 5.  RE: HTTP API Call using Java compute node?

    Posted Tue April 08, 2025 08:51 AM

    Bad design decision. Use the HTTP Request node!



    ------------------------------
    Francois Brandelik
    ------------------------------



  • 6.  RE: HTTP API Call using Java compute node?

    Posted Tue April 08, 2025 09:50 AM

    Thanks. But just want to know even after passing keystore , truststore details it is throwing SSLHandshakeException: Certificate_unknown. 

    Do we have the provision to call HTTP call frm JCN node?



    ------------------------------
    Rukmani T
    ------------------------------



  • 7.  RE: HTTP API Call using Java compute node?

    Posted Wed April 09, 2025 03:52 AM

    Rukmani,

    Why wouldn't you use a http request node like Kim and Francois recommended? I completly agree with them. You should use out of the box functionality when it is available.

    Is it because you don't want to refactor your code too much ? Not sure if you know this but you can propagate a message inside you java code and save the response in the Environment tree. In your code you can then access the response. Depending on the use case better alternatives exist. 

    Can you eloborate on why you don't want to introduce a new node ? Or can you share you java code ? 



    ------------------------------
    Jef Jansen
    Integration Architect
    IntegrationDesigners.com
    Kontich
    ------------------------------