Apache configuration on AS400 for SSL connection

0 pts.
Tags:
AS/400
Hi, I need to configure APACHE HTTP SERVER on AS400 for SSL Connections. I also need to access CL programs, I mean calling CL programs from WEB residing on a specific library in AS400. Could you let me know the methods for this.
ASKED: October 21, 2005  10:46 AM
UPDATED: October 21, 2005  5:24 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

For SSL, I have never tested. But for CL calling, i have used net.data scripting:

-1- apache conf in …httpd.conf :
MapMatch ^/EcartPrix/Historique$ /QSYS.LIB/VCEHTTP.LIB/DB2WWW.PGM/QSYS.LIB/VCEHTTP.LIB/Qpgmsrc.FILE/NETDATA.MBR/HISTO

this line maps public link “/EcartPrix/Historique” to DB2WWW.PGM net.data interpreter (it could be directly your own pgm if you have a sample of program for handling web dialog. I have not – CGIDEV2 ? -)
DB2WWW is furnished by IBM. It is recommended to make a copy in working directory. here it is “/QSYS.LIB/VCEHTTP.LIB/”. if necessary, I can retrieve doc about.
the rest of the link give the path to the net.data macro (here it is “/QSYS.LIB/VCEHTTP.LIB/Qpgmsrc.FILE/NETDATA.MBR”) and the starting macro (here “HISTO”)

IE you uses SEU to update the macro.
it works, but now I prefer putting my macro in the IFS and maintain the macros with notepad.
In this case, apache conf line becomes
MapMatch ^/EcartPrix/Historique$ QSYS.LIB/VCEHTTP.LIB/DB2WWW.PGM//MyIfsDir/myMacro.txt/HISTO

-2-the net.data source member :
!!! search 400 forbid html tag. hereafter, replace &lt& with lessthan and &gt& with greaterthan

%FUNCTION(DTW_SYSTEM) pgmdirlist (IN DIRNAME, OUT DIRLIST) {
%EXEC {
/QSYS.LIB/VCEHTTP.LIB/ECARTPRIX.PGM
%}
%}

%DEFINE {
MYLIST = “”
%}

%HTML(Histo) {
&lt&HTML&gt&
&lt&HEAD&gt&
&lt&TITLE&gt&Suivi des ecarts de prix.&lt&/TITLE&gt&
&lt&/HEAD&gt&
&lt&BODY LINK=”#0000ff” VLINK=”#800080″&gt&
&lt&A href=”ECART.XLS”&gt&Ecarts de prix du jour&lt&/A&gt&
&lt&P&gt&&lt&/P&gt&
&lt&table bgColor=silver background=”" border=1&gt&
&lt&TR&gt&
&lt&TH&gt&Fichier Excel&lt&TH ALIGN=RIGHT&gt&Taille
@pgmdirlist(“/VCEHTTP/EcartDePrix”, MYLIST)
$(MYLIST)
&lt&/table&gt&
&lt&/BODY&gt&&lt&/HTML&gt&
%}

%HTML(HelloWorld) {
&lt&P&gt&Hello the World
%}

in net.data syntax, an html entry point is a %HTML
here, it’s %HTML(Histo) {
This macro return some html code and the output of “@pgmdirlist” a system call (%FUNCTION(DTW_SYSTEM)) to my program /QSYS.LIB/VCEHTTP.LIB/ECARTPRIX.PGM

hereafter is the complete code of the program

here is some explanations

net.data insert in the shell variables list the 2 declarations (DIRNAME, DIRLIST) then load DIRNAME with provided parameter then call the native code then retrieve DIRLIST

the reverse side, my pgm retrieve DIRNAME with QtmhGetEnv and load DIRLIST with QtmhPutEnv

now you are interested with using
Dgetenv PR extproc(‘QtmhGetEnv’)
Dputenv PR extproc(‘QtmhPutEnv’)

* read DIRNAME
C eval envNm = ‘DIRNAME’
C eval envNmLn = %len(%trim(envNm))
C callp getenv(envVal:envBufLn:envValLn:
C envNm:envNmLn:qusec)
C Eval directory = envval

* prepare DIRLIST
c eval html = ‘DIRLIST=’
c eval html = html +’<TR&gt&’
c + ‘<TD&gt&’ +
c ‘<A href=”/EcartPrix/’ +
c %trim(name) + ‘”&gt&’ +
c %trim(name) + ‘</A&gt&’ +
c ‘</TD&gt&<TD ALIGN=RIGHT&gt&’ +
c %trim(%editc(st_size:’Z')) +
c ‘</TD&gt&</TR&gt&’
* Set DIRLIST value
C eval envValLn = %len(html)
c eval envval = html
C callp putenv(envval:envValLn:qusec)

the rest of the code is a sample to read a directory. If necessary, I can provide the missing copy qusec. but you would find qsysinc in your 400.

If some french comment make you confuse, feed back, I will translate.

-3- the native program (CLP or RPG, it’s the same context)
h debug
* prototype for QtmhGetEnv API
Dgetenv PR extproc(‘QtmhGetEnv’)
D Valeur 32767
D ValeurLngMax 10i 0
D ValeurLng 10i 0
D Variable 30
D VarLen 10i 0
D ErrorCode 116
* prototype for QtmhPutEnv API
Dputenv PR extproc(‘QtmhPutEnv’)
D VarVal 32767
D VarValLen 10i 0
D ErrorCode 116

* variables used for QtmhGetEnv & QtmhPutEnv calls
DenvVal S 32767
DenvBufLn S 10i 0 inz(%size(envVal))
DenvValLn S 10i 0
DenvNm S 30
DenvNmLn S 10i 0
* Error data structure from openness library, QSYSINC.
* If not present, it can be installed (it comes with
* OS/400 as part of the System Openness Includes component).
/copy qsysinc/qrpglesrc,qusec
D QUSMSGDTA 100
* Initialize the error data structure’s bytes-provided subfield

D Directory S 1024
D Html S 32767 varying
D DateIso S 10
D DateFichier S D
D DateMin S D
D DateJour S D inz(*sys)

* pour opendir
D RC S 10I 0
D path S 10A
D pathx S 10A
D pathp S * INZ
D diropn S 10I 0
D diropnp S * INZ
* pour readdir
Dentry ds BASED(entryp)
D reserv1 16
D filenogenid 10U 0
D fileno 10U 0
D reclen 10U 0
D reserv3 10I 0
D reserv4 8A
D ccsid 10I 0
D countryid 2A
D langid 3A
D nlsreserv 3A
D namelen 10I 0
D namedir 256
D entryp S *
Dname s 50
Dnamefile s 50
*
* pour stat – attributs du fichier *stmf
Dstatdta ds 131
D st_mod 10U 0
D st_ino 10U 0
D st_nlink 10U 0
D st_uid 10U 0
D st_gid 10U 0
D st_size 10U 0
D st_atime 10U 0
D st_mtime 10U 0
D st_ctime 10U 0
D st_dev 10U 0
D st_blksize 10U 0
D st_allocsize 10U 0
D st_objtype 10A
*
Dnomifs s 256
Dstatp S * INZ
Dpathtot s 256
Dpathtotp s * INZ
Dpathtotlg s 4 0
Dperrorp s * INZ
Dperrordta s 20 INZ(‘path() error’)
*** on integre le prototypage des fonctions C
Dperror PR 10I 0 EXTPROC(‘perror’)
Dconst * VALUE

Dsprintf PR 10I 0 EXTPROC(‘sprintf’)
D * VALUE
D * VALUE
D 10I 0 VALUE OPTIONS(*NOPASS)
D * VALUE OPTIONS(*NOPASS)

* Open Operations
* value returned = file descriptor 0 (OK), -1 (Error)

Dopen PR 10I 0 EXTPROC(‘open’)
D * VALUE
D 10I 0 VALUE
D 10U 0 VALUE OPTIONS(*NOPASS)
D 10U 0 VALUE OPTIONS(*NOPASS)

* Read Operations
* value returned = number of bytes read or , -1 (Error)

Dread PR 10I 0 EXTPROC(‘read’)
D 10I 0 VALUE
D * Value
D 10U 0 VALUE

* Write Operations
* value returned = number of bytes Written or , -1 (Error)

Dwrite PR 10I 0 EXTPROC(‘write’)
D 10I 0 VALUE
D * VALUE
D 10U 0 VALUE

* Close Operations
* value returned = 0 (OK) or , -1 (Error)

Dclose PR 10I 0 EXTPROC(‘close’)
D 10I 0 VALUE

* Open Directory Operation
* value returned = file descriptor 0 (OK), -1 (Error)

Dopendir PR * EXTPROC(‘opendir’)
D * VALUE

* Read Directory Operation
*

Dreaddir PR * EXTPROC(‘readdir’)
D * VALUE

* Open Directory Operation
* value returned = 0 (OK) or , -1 (Error)

* stat file Operation
*

Dstat PR 10I 0 EXTPROC(‘stat’)
D * VALUE
D * VALUE

Dclosedir PR 10I 0 EXTPROC(‘closedir’)
D * VALUE

* Unlink a File from system… Delete File
* value returned = 0 (OK) or , -1 (Error)

Dunlink PR 10I 0 EXTPROC(‘unlink’)
D * VALUE

C eval qusbprv =116 qusec leng
c datejour subdur 30:*D datemin
* Lire la variable DIRNAME
C eval envNm = ‘DIRNAME’
C eval envNmLn = %len(%trim(envNm))
C callp getenv(envVal:envBufLn:envValLn:
C envNm:envNmLn:qusec)
* initialiser la reponse

c eval html = ‘DIRLIST=’

* ouvrir le repertoire
c do opendir
C Eval directory = envval
C Eval pathp = %Addr(directory)
C Eval statp = %Addr(statdta)
* ouverture du repertoire a lister
C EVAL diropnp = opendir(pathp)
C IF diropnp = *null
C leave
C endif
* lecture du repertoire
C do *hival readdir
C eval entryp= readdir(diropnp)
C if entryp = *null
C leave
C endif
C eval name=%subst(namedir:1:namelen)
* on ignore le . et le ..
C if (%subst(name:1:1) = ‘.’)
c iter
c endif
* on prends seulement les fichiers ECART
C if (%subst(name:1:7) <&gt& ‘ECARTDU’)
c iter
c endif
* recents
c eval dateiso= %subst(name:8:10)
c *ISO- movel dateiso datefichier
c if datefichier < datemin
c iter
c endif

c if %subst(directory:2:1) <&gt& ‘ ‘
C eval pathtot = %str(pathp)+ ‘/’+ name
c else
C eval pathtot = %str(pathp)+ name
C end
C Eval pathtotp = %Addr(pathtot)
C eval pathtotlg = %len(%trim(pathtot)) + 1
* ajout du caractere null a la fin du nom
c eval nomifs = pathtot
C eval %str(pathtotp : pathtotlg) = pathtot
* appel de l’API stat pour recuperation du type : *stmf ou directory
C eval rc = stat(pathtotp : statp)
* traitement de l’erreur
C if rc = -1
C Eval perrorp = %Addr(perrordta)
C callp Perror(perrorp)
c leave
c endif
** vous pouvez lancer le traitement sur le fichier trouve
** Le nom du fichier est dans la zone : nomifs
** Le type est contenu dans la zone st_objtype
** st_objtype vaudra *stmf si c’est un fichier ou *dir pour
** directory
C eval namefile=%subst(nomifs:1:50)
C* namefile dsply
C* st_objtype dsply
C* st_blksize dsply

c if st_objtype = ‘*STMF’

* preparer la ligne html
c eval html = html +’<TR&gt&’
c + ‘<TD&gt&’ +
c ‘<A href=”/EcartPrix/’ +
c %trim(name) + ‘”&gt&’ +
c %trim(name) + ‘</A&gt&’ +
c ‘</TD&gt&<TD ALIGN=RIGHT&gt&’ +
c %trim(%editc(st_size:’Z')) +
c ‘</TD&gt&</TR&gt&’
c endif
c enddo readdir
* fermer le repertoire
C callp closedir(pathp)
c enddo opendir
* envoyer la reponse
* Set DIRLIST value
C eval envValLn = %len(html)
c eval envval = html
C callp putenv(envval:envValLn:qusec)

c**************** dump

c seton lr

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following