Original Message:
Sent: Tue May 06, 2025 11:52 AM
From: Sam Byrd
Subject: IWS: retrieving environment variables
I'll have to look into using the Secure transport required option. It doesn't appear to be available when deploying via the cli, only the UI. Since we're deploying 800+ endpoints we have it scripted. Looks like we'd have to use a propertiesFile
Also good to know about being able to pass the environment variables in as input parms directly.
------------------------------
Sam Byrd
Original Message:
Sent: Tue May 06, 2025 11:42 AM
From: Nadir K Amra
Subject: IWS: retrieving environment variables
You have multiple ways. Easiest is simply indicate when you deploy the web service that it must use TLS. There is a panel that has a line like the following:
Secure transport required: [YES | NO]
Alternatively, look for the presence of "https://" in the URL via the REMOTE_URL environment variable. By the way. if this is a REST web service, you can pass these types of information directly to a procedure input parameter directly. forgoing the need to deal with environment variables. Same with HTTP headers.
------------------------------
Nadir K Amra
Original Message:
Sent: Tue May 06, 2025 11:31 AM
From: Sam Byrd
Subject: IWS: retrieving environment variables
That would definitely make you the definitive source of truth :).
The business problem I'm trying to solve is I've been asked to make it so our APIs only work if they are being accessed via a TLS session, so I was hoping to be able to programmatically access those environment variables set by Apache. Any thoughts on how I might be able to validate that TLS is indeed being used?
Sam
------------------------------
Sam Byrd
Original Message:
Sent: Tue May 06, 2025 11:24 AM
From: Nadir K Amra
Subject: IWS: retrieving environment variables
I am the lead developer for IWS :-) But you will get that information when you deploy an IWS web service and press help on the panel that lists what information should be passed as environment variables to the web service implementation code. Here is the help text:
Specify transport information to be passed to the web service implementation code
Use the panel to specify what transport information related to the web service request is to be passed to the web service implementation code. For web service implementation code written in an ILE language, the information is passed in environment variables.
For example, if the transport metadata REMOTE_ADDR is selected, it will be passed to the web service implementation code in an environment variable named REMOTE_ADDR.
HTTP headers indicates what transport headers (e.g. HTTP headers) to pass to the web service implementation code. The environment variable name for HTTP headers is made up of the specified HTTP header prefixed with HTTP_, all upper-cased. For example, if Content-type is specified, then the environment variable name would be HTTP_CONTENT-TYPE. If an HTTP header was not passed in on the web service request, the environment variable value will be set to the null string.
------------------------------
Nadir K Amra
Original Message:
Sent: Tue May 06, 2025 11:17 AM
From: Sam Byrd
Subject: IWS: retrieving environment variables
Nadir,
Thanks for the response, I don't suppose you have a source for that do you? I'll say I agree based on the empirical evidence of my testing. I think Gemini may have been hallucinating (it can't give me a straight forward answer as to where it found that information) when it sent me down the path that IWS is built on top of Apache HTTP therefore it has access to all of Apache's environment variables.
Sam
------------------------------
Sam Byrd
Original Message:
Sent: Tue May 06, 2025 11:03 AM
From: Nadir K Amra
Subject: IWS: retrieving environment variables
The link you show are only for Apache HTTP servers. For IWS, you can only get at HTTP headers or a handful of transport metadata, which are listed below:
QUERY_STRING
REMOTE_ADDR
REMOTE_USER
REQUEST_METHOD
REQUEST_URI
REQUEST_URL
SERVER_NAME
SERVER_PORT
------------------------------
Nadir K Amra
Original Message:
Sent: Fri May 02, 2025 03:33 PM
From: Sam Byrd
Subject: IWS: retrieving environment variables
I have a series of services deployed to IWS. I'm needing to retrieve some of the environment variables set by the underlying http server. In my current deployment I have TLS configured at the IWS level so I can utilize a java key store to manage my certificates. I have my service configured to pass through the AUTHORIZATION header from the client and can retrieve it using GetEnv and then a memory tag of HTTP_AUTHORIZATION. However, if I try to retrieve say the HTTPS variable as defined by the link shared below using a tag of either HTTP_HTTPS or just HTTPS it fails. If I add HTTPS to my list of "transport headers" and retrieve using HTTP_HTTPS I get a hit, but it's always a null byte (unless I explicitly pass it from my client).
Anyone have any insight into how I might go about retrieving these variables? Note that I've tried several different variables defined by the above. Based on my research IWS runs on top of Liberty which in turn incorporates Apache and mod_ssl so these variables "should" be available.
Sam
Link from above: https://www.ibm.com/docs/sl/i/7.3.0?topic=information-environment-variables
------------------------------
Sam Byrd
------------------------------