Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XUCERT

XUCERT.m

Go to the documentation of this file.
  1. XUCERT ;ISD/HGW Kernel PKI Certificate Utilities ;09/13/2019 12:25
  1. ;;8.0;KERNEL;**659,701**;Jul 10, 1995;Build 0
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. VALIDATE(DOC,ERR) ;Extrinsic Function.
  1. ;Validate the signatures in a digitally signed XML document which contains an EncryptedData element and EncryptedKey elements.
  1. ; Input: DOC = This string is either a closed reference to a global root containing the XML document or a filename
  1. ; and path reference identifying the XML document on the host system. See the Kernel Developers Guide
  1. ; documentation on $$EN^MXMLDOM() for detailed requirements for the format of the input global.
  1. ; Return: Fail = "-1^Error Message"
  1. ; Success = 1
  1. ;
  1. ;ZEXCEPT: %New,%XML,Document,OpenFile,OpenStream,Reader,ValidateDocument,class ;ObjectScript
  1. N XUREAD,XUSIG,XUSTATUS,XUVER
  1. S XUREAD=$$READER^XUCERT1(DOC) ;Read XML document
  1. I $G(XUREAD)["-1^" S ERR("PARSE")="" Q 0
  1. S XUSIG=$$SGNTR^XUCERT1(XUREAD) ;Find digital signature
  1. I $G(XUSIG)["-1^" S ERR("NO-SIGNATURE")="" Q 0
  1. D GETISSUE(XUSIG) ;Save subject of X509 certificate (issuer of signature)
  1. ;p701;S XUVER=$$VERSION^%ZOSV() S XUVER=$P(XUVER,".",1)_"."_$P(XUVER,".",2)
  1. S XUSTATUS=$$VAL2^XUCERT1(XUREAD,XUSIG,.ERR)
  1. Q XUSTATUS
  1. ;
  1. GETISSUE(SIG) ;Subroutine. Save X509 Certificate owner to XOBDATA("XOB RPC","SAML",ISSUER")
  1. ;ZEXCEPT: Encryption,X509GetField,XOBDATA ;ObjectScript and environment variables
  1. N CERT
  1. S CERT=$$CERT^XUCERT1(SIG)
  1. I +CERT=-1 Q ;Cannot get certificate
  1. S XOBDATA("XOB RPC","SAML","ISSUER")=$System.Encryption.X509GetField(CERT,"Subject")
  1. Q
  1. ;
  1. TEST ;Subroutine. System checks to help with troubleshooting.
  1. ;Check if Cache version >= 2015.2
  1. ; 12345678901234567890123456789012345678901234567890123456789012345678901234567890
  1. W !,"XML digital signature validation is done differently depending on the version"
  1. W !,"of Cache being used on your system:"
  1. W !," Versions greater than or equal to 2015.2 use $$VAL1^XUCERT1"
  1. W !," Versions less than 2015.2 use $$VAL2^XUCERT1"
  1. W !," Your Cache Version is ",$$VERSION^%ZOSV(),!
  1. ;
  1. ;Check if PKI chain of trust to root is available (how?)
  1. ; ** Apparently Cache uses OpenSSL on underlying server for chain of trust. Check OpenSSL version?
  1. ;Check if %SuperServer and %TELNET/SSL is available (how? with https?)
  1. ; ** Is this still needed?
  1. ;Check if a local X.509 certificate is installed (how? same as %SuperServer check?)
  1. ; ** Not needed. All sites use SSL, so they have a certificate on the server.
  1. Q
  1. ;