Skip to content

Instantly share code, notes, and snippets.

@radzhome
Created July 24, 2015 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radzhome/f00ae86478e7ece8921c to your computer and use it in GitHub Desktop.
Save radzhome/f00ae86478e7ece8921c to your computer and use it in GitHub Desktop.
/* REXX */
/* To connect a certificate to keyrings same was as another */
/* certificate, pretty much duplicate its keyring usage as */
/* that of an existing Nov 2010 */
/*outtrap racdcert site and ca output*/
/* Your label will be located from the below query so make sure it */
/* contains what you need!*/
x = OUTTRAP('strRacfLs.')
Address TSO 'RACDCERT SITE LIST'
Address TSO 'RACDCERT CERTAUTH LIST'
/*Address TSO 'RACDCERT ID(XXX) LIST' OPTIONAL IF CLONING ID RING */
/*Address TSO "RACDCERT CERTAUTH LIST(LABEL('RSA Secure Server CA'))"*/
y = OUTTRAP('OFF')
/* stat = msg(off) */
CloneLabel="SSL WASGCC Site RACF" /* change to desired label */
NewLabel="SSL WASGCC Site - G5" /* new label for duplicate cer */
strLabel=""
stopAfterLabel=1 /* special variable lets you control if you */
strRing.0=0 /* want to create for all found rings or only */
/* matching the label spcified in CloneLabel */
/* more advanced option. Leave 1 recommended */
call AllocateOutputFile
intCount=1
found=0
do i = 1 to strRacfLs.0
k=i
strLabel= substr(strRacfLs.i,10)
if word(strRacfLs.i,1) = 'Label:' then do
strLabel = CloneLabel
found=1
if strLabel=CloneLabel then do
do k = i+1 to strRacfLs.0 /* nxt line*/
call GetRingInformation
end
end
else if word(strRacfLs.i,1) = 'Label:',
|| strLabel <> CloneLabel then do
strLabel= substr(strRacfLs.i,10)
leave
end
end
if found=1 then leave
end
Call WriteCommand
Call CloseFile
exit
GetRingInformation:
if stopAfterLabel=1 then do
if word(strRacfLs.k,1) = 'Label:' then do
strLabel= substr(strRacfLs.k,10)
end
end
if strLabel = CloneLabel then do
if word(strRacfLs.k,1)= 'Ring' & word(strRacfLs.k,2)= 'Owner:' then do
l=k+2
strRing.0=intCount
tmpOwn=space(substr(strRacfLs.k,17))
tmpRing=space(word(strRacfLs.l,1))
tmpRing=TrimRing(tmpRing)
x = OUTTRAP('strLsRing.')
Address TSO 'RACDCERT ID(' tmpOwn ') LISTRING(' tmpRing ')'
y = OUTTRAP('OFF')
do m=1 to strLsRing.0
tmplabel=substr(strLsRing.m,3,length(CloneLabel))
if tmplabel = CloneLabel then do
strLsRingFd=space(substr(strLsRing.m,length(CloneLabel)+4))
strRing.intCount=tmpOwn||'&;;;;&',
||tmpRing||'&;;;;&',
||space(word(strLsRingFd,1))||'&;;;;&',
||space(word(strLsRingFd,2))'&;;;;&',
||word(strLsRingFd,3)
/* say strLabel
say strRing.intCount
parse pull */
end
end
intCount=intCount+1
end
end
Return
TrimRing: PROCEDURE
parse arg strRing
if Pos('>',strRing,1)<> 0 then do
tmpstart=Pos('>',strRing,1)+1
tmpend=lastpos('<',strRing)-1
/*strRing=substr(strRing,1,tmpend)||,
substr(strRing,tmpstart,length(strRing)-tmpstart+1) */
strRing=substr(strRing,tmpstart,tmpend-1)
end
Return strRing
AllocateOutputFile:
"DELETE '"Q34JVVW.CERTS.CONNECT.RERING"' "
"FREE F(OUTDD2)"
"ALLOC F(OUTDD2) DA('"Q34JVVW.CERTS.CONNECT.RERING"') NEW",
"RECFM(F B) SP(300 150) BLKSIZE(0) LRECL(256) UNIT(SYSDA) "
return
CloseFile:
l1 =" SETR RACLIST(DIGTNMAP DIGTCERT DIGTRING DIGTCRIT) REF"
PUSH l1
"EXECIO 1 DISKW OUTDD2"
"FREE F(OUTDD2)"
say 'Output Command Dataset Created.'
return
WriteCommand:
strRing.0=intCount
do z=1 to strRing.0
c1stps=Pos('&;;;;&',strRing.z,1)
c2ndps=Pos('&;;;;&',strRing.z,c1stps+1)
c3rdps=Pos('&;;;;&',strRing.z,c2ndps+1)
c4thps=Pos('&;;;;&',strRing.z,c3rdps+1)
if c1stps <> 0 then do
tmpown=substr(strRing.z,1,c1stps-1)
tmprin=substr(strRing.z,c1stps+6,c2ndps-c1stps-6)
tmptype=substr(strRing.z,c2ndps+6,c3rdps-c2ndps-6)
tmpusg=substr(strRing.z,c3rdps+6,c4thps-c3rdps-6)
tmpdefault=space(substr(strRing.z,c4thps+6))
l1="racdcert id("tmpown,
||") connect("tmptype,
||" label('"NewLabel"') ring("tmprin")",
||" usage("tmpusg")"
if tmpdefault="YES" then do
l1=l1||" default)"
end
else do
l1=l1||")"
end
PUSH l1
"EXECIO 1 DISKW OUTDD2"
end
end
return
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
//*
strOutDSN = SYSVAR(SYSUID) || ".CERTS.KEYRING"
blnStat = msg(off)
"DELETE '"strOutDsn"' "
blnReplaceFile=0
if RC = 0 then do
blnReplaceFile=1
end
"FREE F(OUTDD)"
"ALLOC F(OUTDD) DA('"strOutDsn"') NEW",
"RECFM(F B) SP(100 50) BLKSIZE(0) LRECL(150) UNIT(SYSDA) "
blnStat = msg(on)
if RC=0 then do
if blnReplaceFile=1 then do
say 'Dataset' strOutDsn 'deleted and allocated Successfuly.'
end
else do
say 'Dataset' strOutDsn 'allocated Successfuly.'
end
end
else do
say 'Dataset not allocated - Cannot Allocated Output JCL Dataset' strOutDsn,
||'.'
end
blnStat = msg(off)
do i = 1 to strRec.0 -1
PUSH strRec.i
"EXECIO 1 DISKW OUTDD"
end
"FREE F(OUTDD)"
Exit
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment