Certificate expiration date

341 views
Skip to first unread message

trepao2...@gmail.com

unread,
Feb 9, 2024, 4:17:08 AM2/9/24
to Harbour Users
Hello,

Without using openssl, is there any way by command or harbour function to know the expiration date of a certificate in .pem format?

regards

bernardm...@gmail.com

unread,
Feb 9, 2024, 7:35:14 AM2/9/24
to Harbour Users
Hello,
I have a code with Windows but it runs as administrator.
Regards,
Bernard.

// begin code.
/* Certicates console to csv file.

This code is a basic sample for tests.

Obtenir les certificats de l'ordinateur vers fichier.csv.

Ce code est disponible dans l'état sans aucune garantie.
Le risques de l'utilisation de ce code est sous la responsabilité de l'utilisateur,
que ce code soit dans l'état ou avec des modifications qui sont autorisées.

Ce programme crée un fichier exécutable en VB script qui va lui-même
créer un fichier.csv que l'on peut ouvrir avec Excel ou Open Office.
Certaines commandes VB Script ne fonctionnent pas avec dBase.
On fabrique le fichier.csv en VB Script et on le récupère en dBase.
Une question est posée si on veut lancer le programme VB script
car il faut lancer le programme en tant qu'Administrateur.

Compile with -lhbwin

*/

// Change this parameters.
#define VARIABLE_SEPARATEUR " ; "                          // Columns separator.
#define MAX_COLONNES        "10"                           // Maximum number of columns to retrieve.
#define FILE_VBS hb_dirbase() + "_Result.vbs"              // VBScript program.
#define FILE_CSV hb_dirbase() + "_Result.csv"              // CSV output file.

procedure main

   local cStringe := ""

   request HB_CODEPAGE_FRWIN
   hb_cdpSelect( 'FRWIN' )
   setmode( 25, 80 )

   ferase( FILE_VBS )
   ferase( FILE_CSV )

   // Create the VBS file.
   cStringe += "'Get the computer certificates in an Excel file." + hb_eol()
   cStringe += hb_eol()
   cStringe += "'This code is available in the state without any warranty." + hb_eol()
   cStringe += "'The risk of using this code is the responsibility of the user," + hb_eol()
   cStringe += "'Whether that code is in the state or with changes that are allowed." + hb_eol()
   cStringe += hb_eol()
   cStringe += "'You can change the folder name below if you want." + hb_eol()
   cStringe += "'Create a shortcut -> wscript.exe " + '"' + FILE_VBS + '"' + hb_eol()
   cStringe += "'and run with Administritor rights." + hb_eol()
   cStringe += hb_eol()
   cStringe += 'Option Explicit' + hb_eol()
   cStringe += 'Dim oTrans' + hb_eol()
   cStringe += 'Set oTrans = CreateObject( "Scripting.FileSystemObject" )' + hb_eol()
   cStringe += 'Dim oTransF' + hb_eol()
   cStringe += hb_eol()
   cStringe += "'You can change the folder name below if you want." + hb_eol()
   cStringe += 'Set oTransF = oTrans.OpenTextFile( "' + FILE_CSV + '", 2, True )' + hb_eol()
   cStringe += 'Dim objMMC' + hb_eol()
   cStringe += 'Set objMMC = CreateObject( "MMC20.Application" )' + hb_eol()
   cStringe += 'objMMC.Load( "certmgr.msc" )' + hb_eol()
   cStringe += 'Dim objDoc' + hb_eol()
   cStringe += 'Set objDoc = objMMC.Document' + hb_eol()
   cStringe += 'Dim objSN' + hb_eol()
   cStringe += 'Set objSN = objDoc.ScopeNamespace' + hb_eol()
   cStringe += 'Dim objRoot' + hb_eol()
   cStringe += 'Set objRoot = objDoc.RootNode' + hb_eol()
   cStringe += 'Dim objEvtVwrNode' + hb_eol()
   cStringe += 'Set objEvtVwrNode = objSN.GetChild( objRoot )' + hb_eol()
   cStringe += 'objSN.Expand( objEvtVwrNode )' + hb_eol()
   cStringe += 'Dim objView' + hb_eol()
   cStringe += 'Set objView = objDoc.ActiveView' + hb_eol()
   cStringe += 'On Error Resume Next' + hb_eol()
   cStringe += 'Dim objNode' + hb_eol()
   cStringe += 'Set objNode = Nothing' + hb_eol()
   cStringe += 'Set objNode = objSN.GetChild( objEvtVwrNode )' + hb_eol()
   cStringe += 'If ( objNode Is Nothing ) then' + hb_eol()
   cStringe += '   oTransF.writeline "** Error : objNode Is Nothing, quit."' + hb_eol()
   cStringe += '   oTransF.Close' + hb_eol()
   cStringe += '   Wscript.quit' + hb_eol()
   cStringe += 'End If' + hb_eol()
   cStringe += 'Do Until ( objNode Is Nothing )' + hb_eol()
   cStringe += '   objSN.Expand( objNode )' + hb_eol()
   cStringe += '   objView.ActiveScopeNode = objNode' + hb_eol()
   cStringe += '   Dim cFolder' + hb_eol()
   cStringe += '   Set cFolder = Nothing' + hb_eol()
   cStringe += '   Set cFolder = objSN.GetChild( objNode )' + hb_eol()
   cStringe += '   Do Until ( cFolder Is Nothing )' + hb_eol()
   cStringe += '      objSN.Expand( cFolder )' + hb_eol()
   cStringe += '      objView.ActiveScopeNode = cFolder' + hb_eol()
   cStringe += '      Dim objList' + hb_eol()
   cStringe += '      Set objList = objView.ListItems' + hb_eol()
   cStringe += '      Dim objItem' + hb_eol()
   cStringe += '      For Each objItem In objList' + hb_eol()
   cStringe += '         Dim str' + hb_eol()
   cStringe += '         str = objView.CellContents( objItem, 1 )' + hb_eol()
   cStringe += '         If (str <> "Error") Then' + hb_eol()
   cStringe += '            Dim cLine' + hb_eol()
   cStringe += '            Dim I' + hb_eol()
   cStringe += '            cLine = objNode.Name + "' + VARIABLE_SEPARATEUR + '" + cFolder.Name' + hb_eol()
   cStringe += '            For I = 1 To ' + MAX_COLONNES + hb_eol()
   cStringe += '               cLine = cLine + "' + VARIABLE_SEPARATEUR + '" + objView.CellContents( objItem, I )' + hb_eol()
   cStringe += '            Next' + hb_eol()
   cStringe += '            oTransF.writeline cLine' + hb_eol()
   cStringe += '         End If' + hb_eol()
   cStringe += '      Next' + hb_eol()
   cStringe += '      Dim objSib2' + hb_eol()
   cStringe += '      Set objSib2 = Nothing' + hb_eol()
   cStringe += '      Set objSib2 = objSN.GetNext( cFolder )' + hb_eol()
   cStringe += '      Set cFolder = objSib2' + hb_eol()
   cStringe += '   Loop' + hb_eol()
   cStringe += '   Dim objSib' + hb_eol()
   cStringe += '   Set objSib  = Nothing' + hb_eol()
   cStringe += '   Set objSib  = objSN.GetNext( objNode )' + hb_eol()
   cStringe += '   Set objNode = objSib' + hb_eol()
   cStringe += 'Loop' + hb_eol()
   cStringe += 'oTransF.Close' + hb_eol()
   cStringe += 'Wscript.quit'
   hb_memowrit( FILE_VBS, cStringe )

   wapi_ShellExecute( 0 ;
                  , "runas" ;                // Open with the Administrator rights.
                  , "wscript.exe" ;          // Appli to open.
                  , FILE_VBS ;               // Parameters.
                  , SET( "DIRECTORY" ) ;     // Folder.
                  , 1 )                      // Display mode.

   return
// End code.

diego...@gmail.com

unread,
Feb 27, 2024, 6:47:47 AM2/27/24
to Harbour Users
crt.prg
crt.c

leonardo...@hotmail.com

unread,
Feb 28, 2024, 12:01:34 PM2/28/24
to Harbour Users
This example is very good, is there any way to sign xml using OpenSSL?

Leonardo Machado.

Marcelo Antonio Lázzaro Carli

unread,
Feb 28, 2024, 12:07:57 PM2/28/24
to harbou...@googlegroups.com

Can you sign an xml with sha256?

 

 

Att.

 

                Marcelo A. L. Carli

                      Marília/SP

         Capital Nacional do Alimento ®

      https://malc-informatica.ueniweb.com

                 Insta: @malcarli25

      Email / Skype: marcelo...@gmail.com

 

******************************************************************************

Se for repassar, apague o meu nome e endereço.

Ajude a combater a propagação de vírus e spams

coloque TODOS os destinatários em CÓPIA OCULTA (Cco / Bcc)

******************************************************************************

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/178c7a54-85d9-4406-8d27-cf34f985ae7cn%40googlegroups.com.


Não contém vírus.www.avast.com

diego...@gmail.com

unread,
Feb 28, 2024, 12:40:25 PM2/28/24
to Harbour Users
Yes, you can sign SHA256 and others using openssl api C from harbour.
I used it for e-invoice. 

Marcelo Antonio Lázzaro Carli

unread,
Feb 28, 2024, 1:03:22 PM2/28/24
to harbou...@googlegroups.com

you have examples. Thanks

Marek Olszewski "MOL"

unread,
Nov 12, 2025, 2:58:08 PM (12 days ago) Nov 12
to Harbour Users
can you post a sample how to sign XML file with .CRT cerificate?
Reply all
Reply to author
Forward
0 new messages