PowerBuilder
PowerBuilder
Get Certificate Valid To/From Dates
Demonstrates how to get the certificate "valid from" and "valid to" dates.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Cert
oleobject loo_Ckdt
oleobject loo_Dt
li_Success = 0
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
if li_rc < 0 then
destroy loo_Cert
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Cert.LoadFromFile("qa_data/certs/testCert.cer")
if li_Success = 0 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Cert
return
end if
// Get the certificate valid-from date/time
loo_Ckdt = create oleobject
li_rc = loo_Ckdt.ConnectToNewObject("Chilkat.CkDateTime")
loo_Ckdt.SetFromRfc822(loo_Cert.ValidFromStr)
// Get the local timestamp string.
Write-Debug "Valid from: " + loo_Ckdt.GetAsTimestamp(1)
// Valid from: 2017-03-17T19:00:00-05:00
// Now get the date/time as another object where we can get the individual numeric date parts.
loo_Dt = create oleobject
li_rc = loo_Dt.ConnectToNewObject("Chilkat.DtObj")
loo_Ckdt.ToDtObj(1,loo_Dt)
Write-Debug string(loo_Dt.Day) + "/" + string(loo_Dt.Month) + "/" + string(loo_Dt.Year) + " " + string(loo_Dt.Hour) + ":" + string(loo_Dt.Minute)
// Get the certificate valid-to date/time
loo_Ckdt.SetFromRfc822(loo_Cert.ValidToStr)
Write-Debug "Valid to: " + loo_Ckdt.GetAsTimestamp(1)
// Valid to: 2020-03-18T18:59:59-05:00new DtObj dt;
loo_Ckdt.ToDtObj(1,loo_Dt)
Write-Debug string(loo_Dt.Day) + "/" + string(loo_Dt.Month) + "/" + string(loo_Dt.Year) + " " + string(loo_Dt.Hour) + ":" + string(loo_Dt.Minute)
destroy loo_Cert
destroy loo_Ckdt
destroy loo_Dt