Question
· 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
Discussion (2)2
Log in or sign up to continue

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 name
ClassMethod SSLDetails(SSLName As %String = "") As %Status
{
	new $namespace
	set $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  details
	for 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"