Question Padmaja Konduru · Sep 19, 2023

How to get Customized SSL/TLS certificate expiry alerts using ObjectScript

Hi,

I want to write a class to write a customized SSL/TLS certificate expiry alerts using ObjectScript?

Any sample code for reference available?

Thanks, 

Product version: IRIS 2020.1

Comments

Ashok Kumar T · Sep 20, 2023

Hello @Padmaja Konduru 

The certificate and private key is configured for the your SSL/TLS connection.  You can try  executing the below code to get some certificates of the certificate

I have attached my sample "test" SSL/TLS which is included the sample certificate and private key (x509)

Call the SSLDetails method with your SSL name. This method will return an local array with some basic details like expire date , subject and so on.  SSL configuration name was taken from the   System > Security Management > SSL/TLS Configurations 

/// Call this method with your ssl nameClassMethod SSLDetails(SSLName As%String = "") As%Status
{
	new$namespaceset$namespace="%SYS"set ssl=##class(Security.SSLConfigs).%OpenId("test")
	set privateKeyFile = ssl.CertificateFile
	set file = ##class(%FileCharacterStream).%New()
	do file.LinkToFile(privateKeyFile)
	set str=file.Read($$$MaxLocalLength)
	do..certificateDetails(str,.fields)
	zw fields
	return$$$OK
}

ClassMethod certificateDetails(str As%String, ByRef fields)
{
	#;getting some basic  detailsfor field="SerialNumber","Issuer","ValidityNotAfter","ValidityNotBefore","Subject","SubjectKeyIdentifier" {
		set fields(field) = $SYSTEM.Encryption.X509GetField(str,field)
	}
}

output

verify the local array fields("ValidityNotAfter") value for the expired date

IRISMYDEV>do ##class(Sample.NewClass1).SSLDetails("test")
fields("Issuer")="L=test,CN=test,O=test,ST=test,C=us"
fields("SerialNumber")=0
fields("Subject")="L=test,CN=test,O=test,ST=test,C=us"
fields("SubjectKeyIdentifier")=$c(144)_"¾&p"_$c(28)_"áÁZÀ"_$c(140)_"Ô4OÜ"_$c(24)_"º""=B"_$c(137)
fields("ValidityNotAfter")="2023-09-21 06:13:50"
fields("ValidityNotBefore")="2023-09-20 06:13:50"
 
0
Padmaja Konduru  Sep 20, 2023 to Ashok Kumar T

Thank you Ashok! I will try it.

0