To use this function add it to the class library file named PluginBaseService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: PluginBaseService.ts
Function: ValidateCertificate
publicValidateCertificate(strHostFQDN:string):boolean{
try{
// @ts-ignore
letobjConfiguratorKeystores:ConfiguratorKeystores=Config.getKeystores();
// @ts-ignore
letobjConfiguratorImportCAFromUrlAction:ConfiguratorImportCAFromUrlAction=objConfiguratorKeystores.getImportCAFromUrlAction();
// @ts-ignore
letobjHolder:Holder=objConfiguratorImportCAFromUrlAction.getModel();
objHolder.value=strHostFQDN;
// @ts-ignore
letobjCertChainValidatorResult:CertChainValidatorResult=objConfiguratorImportCAFromUrlAction.validateCertificates();
letblnIsCertificateExpired:boolean=objCertChainValidatorResult.isCertificateExpired();
if (blnIsCertificateExpired===true){
this.objLogger.info(`Connection:${strHostFQDN} is Invalid, Certifcate has Expired.`);
returnfalse;
}
elseif (blnIsCertificateExpired===false){
this.objLogger.info(`Connection:${strHostFQDN} is Valid, Certifcate has not Expired.`);
returntrue;
}
}catch (objException){
this.objLogger.info(`Connection:${strHostFQDN} is Invalid. Validation Workflow failed with exception:${objException.toString()}`);
returnfalse;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
