WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System_Security

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Expiration Date of this X509v3 Certificate

 Keywords: Get Expiration Date X509v3 X.509 509 Certificate dotNet x509certificate .cer file CreateFromCertFile GetExpirationDateString System.Security.Cryptography.X509Certificates.X509Certificate CAPICOM

;***************************************************************************
;**   Read Expiration date from a .CER certificate file
;**
;** Purpose: Read Expiration date from a .CER certificate file
;** Inputs:  .cer file path
;** Outputs: Message with expiration date of certificate file
;** Reference:
;**       REQUIRES WinBatch 2013A or newer
;**       dotNet x509certificate class: http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate.getexpirationdatestring(v=vs.90).aspx
;** Developer: Deana Falk 2013.08.28
;***************************************************************************
If Version( )< '2013A'
   Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
   Exit
EndIf

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Load assemblies into the WinBatch process.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; mscorlib assembly is automatically loaded by WinBatch when the CLR is loaded.
;ObjectClrOption ('use','mscorlib, version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Prompt for input
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; The path to the certificate.
strFileName = 'C:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Thawte Root Certificate.cer'

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Associate a Framework based type name with a value.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Create a class implemented by a managed assembly.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Load the certificate into an X509Certificate object.
X509Certificate =  ObjectClrNew( 'System.Security.Cryptography.X509Certificates.X509Certificate' )
cert = X509Certificate.CreateFromCertFile(strFileName);
;Get the value.
results = cert.GetExpirationDateString();
;Display the value
Pause('GetExpirationDateString', results)
Exit

Article ID:   W17840
Filename:   Get Expiration Date of this X509v3 Certificate.txt
File Created: 2013:08:28:10:05:12
Last Updated: 2013:08:28:10:05:12