RPG Free call REST web service ignore certificate error

Discussions relating to writing software in ILE RPG (RPG IV). This includes both fixed and free format RPG.
Post Reply
jim.coker
Posts: 1
Joined: Wed May 03, 2023 8:39 pm

RPG Free call REST web service ignore certificate error

Post by jim.coker »

I am an IBM i RPG developer and I am working on an application that performs a call to a REST web service that resides on a different platform within our own network. This is my first web service application so I am painfully inexperienced! I am able to successfully call the web service using the Postman utility on my windows laptop, and I am also able to call the web service using the SnapLogic platform. I would like to be able to use RPG Free (we are on V7R3M0, with Technology Release 13 installed) to call the web service.

To use the web service in Postman, I have to disable the option "Enable SSL certificate verification (Verify SSL certificates when sending a request. Verification failures will result in the request being aborted.)" To use the web service in SnapLogic, I have to configure it with "Trust all certificates".

WHAT I HAVE TRIED SO FAR:
I have followed the example described in the PowerPoint presentation on this site to call the IBM Watson service to perform a translation from one language to another and it works successfully.

I modified the parameters of that call to point to my own API. I did the following SQL statement to perform the call:

exec SQL
select SYSTOOLS.HTTPPOSTCLOB(:url, :hdr, :request)
into :response
from SYSIBM.SYSDUMMY1;

:url has been updated to point to the same value successfully used with Postman and SnapLogic.
:hdr = <httpHeader><header name="Content-Type" value="application/json; charset=utf-8" /></httpHeader>
:request is a json object that I copied and pasted from Postman to ensure it is properly formatted.

When I run the program in debug, I get SQLSTT = 38000 and SQLCOD = -4302. When I look at the job log, it shows:
Java stored procedure or user-defined function SYSTOOLS.HTTPPOSTCLOB,
specific name HTTPP00013 aborted with an exception
"com.ibm.jsse2.util.j: PKIX path building failed:
com.ibm.security.cert.IBMCertPathBuilderException: unable to find valid
certification path to requested target".

I have tinkered with some different settings but have yet to make any progress. I found some information that suggested I may need to include some options, one of which would be options = '{"sslTolerate": "true"} but I was unable to find an example of actually using that.

Is there something I need to do with the :hdr value to mimic the same behavior as Postman and SnapLogic certificate settings, or else some other problem with the way I have set up the call to my API? Do you know of an example of how to call an API without using the certificate? Any guidance would be very much appreciated!

Thank you,
Jim
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: RPG Free call REST web service ignore certificate error

Post by Scott Klement »

Consider using the newer SQL routines for HTTP rather than the legacy ones in SYSTOOLS

Or, use HTTPAPI -- I know that approach much better, so Im more likey to be able to help you.
Post Reply