Getting expiry date of SSL certificate

Mike Matthews - Omnis omnis at lineal.co.uk
Fri Jan 19 16:59:37 UTC 2024


Together, we are invincible! :)

Mike


On 19 Jan 2024, at 16:24, malkishtini at gmail.com<mailto:malkishtini at gmail.com> wrote:

Caution: This is a message which has originated from outside the organisation. Ensure the sender is trusted and the content is safe before opening links or attachments.


Hi Mike,

Thank you very much for sharing your example.

I just learned something new today.
We can run powershell scripts from studio 11 using oProcess worker object.

You add the code below to a method in your object and call it from another method.

Say the method is called: $runpowershell

Calculate certname as "C:\mycert.crt"
Calculate lArgument as con('powershell.exe dir ',certname,' | %{ $cert = New-Object Security.Cryptography.X509Certificates.X509Certificate2 $_.FullName; echo $cert.NotAfter }')
Do $cinst.$init(lArgument)
Do $cinst.$start()


Overwrite the $complete method and you can do this:
Do $cinst.$readlines(kOProcessStdout) Returns vReturnList
Calculate vExpiryDate as vReturnList.2.stdout

You can read more about in the following tech notes, thank you to Omnis support for providing me with the links.


https://www.technotes.omnis.net/Technical%20Notes/Extending%20Omnis/Using%20the%20oProcess%20Worker/index.html - oProcess explanation

https://www.technotes.omnis.net/Technical%20Notes/Extending%20Omnis/Using%20the%20oProcess%20Worker/4.Complex%20example%3A%20unzipping.html - example of using powershell

Hope that helps 😊.

Regards,
Mayada


From: Mike Matthews - Omnis <omnis at lineal.co.uk<mailto:omnis at lineal.co.uk>>
Sent: Friday, January 19, 2024 10:38 AM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com<mailto:omnisdev-en at lists.omnis-dev.com>>
Cc: malkishtini at gmail.com<mailto:malkishtini at gmail.com>
Subject: Re: Getting expiry date of SSL certificate

Hello Mayada,

I know that part, we use PowerShell for Zipping and unZipping.  We write a BAT file and then use Launch program

1 Make text for command:

Begin text block
Text:@echo off(Carriage return,Linefeed)
Text:powershell -command "Expand-Archive -Path '[Drive][FoldersPath][Name][Ext]' -DestinationPath '[Drive][FoldersPath]' -Force"
End text block
Get text block lvScript

2 Write text to a file:

Do lvFileOps.$createfile(lvBatFilePath) Returns lvErrorMessage

If lvErrorMessage<=1
# Must convert text into utf8 when writing or will put null characters into the file and stop it from working
Do lvFileOps.$writefile(chartoutf8(lvScript))
Do lvFileOps.$closefile()

Close working message ## Force a working mesage for pgdump
For lvLine from 1 to 1000 step 1
Working message Unzip File {[pSourcePath]}
Redraw working message
End For

# Returns an error message rather than code. If successful, returns no message ## RW 2023-02-06
Launch program [lvBatFilePath] Returns lvErrorMessage

# Clean up after ourselves ## RW 2023-02-06
Do FileOps.$deletefile(lvBatFilePath)
Else
Calculate lvFlagOK as kFalse
End If

So what do you write into the PowerShell is my question?

Thanks

Mike








On 19 Jan 2024, at 14:23, malkishtini at gmail.com<mailto:malkishtini at gmail.com> wrote:

Caution: This is a message which has originated from outside the organisation. Ensure the sender is trusted and the content is safe before opening links or attachments.



Hi Mike,
Very good question, we have a way to do it in PowerShell.
https://www.technotes.omnis.net/Technical%20Notes/Extending%20Omnis/Using%20
the%20oProcess%20Worker/2.Implementation.html

So, the question now how to invoke the PowerShell scripts from Omnis studio
on Windows?.

Thank you,
Mayada


-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com<mailto:omnisdev-en-bounces at lists.omnis-dev.com>> On Behalf Of
Mike Matthews - Omnis via omnisdev-en
Sent: Friday, January 19, 2024 8:45 AM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com<mailto:omnisdev-en at lists.omnis-dev.com>>
Cc: Mike Matthews - Omnis <omnis at lineal.co.uk<mailto:omnis at lineal.co.uk>>
Subject: Re: Getting expiry date of SSL certificate

Hello Kelly,

Very lovely thank you.

Who knows how to do this on a Windows machine please?

Mike Matthews

Lineal Software Solutions
Commercial House, The Strand<x-apple-data-detectors://1/1> Barnstaple,
Devon, EX31 1EU<x-apple-data-detectors://1/1>

omnis at lineal.co.uk<mailto:mike.matthews at lineal.co.uk<mailto:omnis at lineal.co.uk%3cmailto:mike.matthews at lineal.co.uk>>

www.lineal.co.uk<http://www.lineal.co.uk/<http://www.lineal.co.uk%3chttp:/www.lineal.co.uk/>>

www.sqlworks.co.uk<http://www.sqlworks.co/<http://www.sqlworks.co.uk%3chttp:/www.sqlworks.co/>>



On 19 Jan 2024, at 03:42, Kelly Burgess
<kellyb at montana.com<mailto:kellyb at montana.com<mailto:kellyb at montana.com%3cmailto:kellyb at montana.com>>> wrote:

Caution: This is a message which has originated from outside the
organisation. Ensure the sender is trusted and the content is safe before
opening links or attachments.



On the Mac, I can do the following to get the expiration date of a named
certificate in my keychain -

      Calculate certname as "Developer ID Application: Kelly Burgess
(76LPV4WMTA)"
      Calculate script as con('security find-certificate -p -c
',kSq,certname,kSq,' | openssl x509 -enddate -noout')
      Calculate script as con('Do shell script ',kDq,script,kDq)
      Do $root.$runapplescript(script,result,error)

That pipes the security find-certificate output to the openssl x509 tool,
and in result I get something I could parse and convert to a date -

      'notAfter=Aug 16 11:11:48 2026 GMT'

Kelly
_____________________________________________________________
Manage your list subscriptions at
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.com&c=E,
1,axgmdEMWPIHUuBcrmrERwCrATH3jSfTM2Tn_o_x5y07nssN5FUhV6ihmr-Xp5jrc62SExy5qX2
45eKG4hpwMWT8Cp6gXcVAkMXWBWuluPNwKhnMZ&typo=1
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com<https://lists.omnis-dev.com/> Start a new
message -> mailto:omnisdev-en at lists.omnis-dev.com




More information about the omnisdev-en mailing list