Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #13325

Re: Work with certificate

From Jamal <nospam@example.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: Work with certificate
Date 2021-06-10 04:04 -0400
Organization Aioe.org NNTP Server
Message-ID <s9sh2j$hkl$1@gioia.aioe.org> (permalink)
References <008ed1ac-5a66-41e3-9fc5-04a91d6e93b8n@googlegroups.com> <s9b4u6$s1a$1@gioia.aioe.org> <7d459deb-8e2e-4813-99d0-dec7c6dccd1an@googlegroups.com>

Show all headers | View raw


I did not work with them (until just now), but you have quite a few 
errors that you must clear in your declarations and loop. I suggest your 
read the ActiveX documentation carefully.

For example:
1. OpenCurrentUserStore() returns a long not a logic.
2. The the loop must start at 0 to numCerts - 1.
3. GetCertificate() returns a ChilkatCert not a string!

I created automation server classes for: IChilkatCertStore and IChilkatCert

Here is a working sample in VO 2.8 - 2838:

METHOD GetCertificates( ) CLASS TestDlg

	local cTexto := "" as string
	local i	as int
	local numCerts	:= 0	as int

	local lReadOnly	:= true	as logic
	local ok as long

	local oCertStore as IChilkatCertStore
	local oChilkatCert as IChilkatCert

         oChilkatCert := IChilkatCert{}

	oCertStore := IChilkatCertStore{}
	
	ok := oCertStore:OpenCurrentUserStore(lReadOnly)
	
	If ok == 0   // error
		InfoBox{self,"error", oCertStore:LastErrorText}:show()
		oCertStore := null_object
		return self
	else
		
		numCerts := oCertStore:NumCertificates
		
		for i := 0 to numCerts - 1
			
			oChilkatCert := oCertStore:GetCertificate(i)
			
			if  oChilkatCert != null_object
			
				cTexto	+=  AsString(oChilkatCert:SubjectDN) +"   -    "+ 
AsString(oChilkatCert:SubjectE) + crlf
			else
				? "oChilkatCert Error: " +  oChilkatCert:LastErrorText
			endif
		next
		
		self:oDCmCert:Value	:=cTexto

		

	endif

	oChilkatCert  := null_object
	oCertStore := null_object


	RETURN self

Note: if you get a class mismatch on oCertStore:GetCertificate(i), 
either make sure you uncheck Class Checking option in Compiler options 
or change the GetCertificate() method to return IChilkatCert class object:

METHOD GetCertificate(;
		index;		// AS LONG
		) CLASS IChilkatCertStore

	LOCAL oMethod  	AS cOleMethod
	LOCAL uRetValue	AS USUAL

	oMethod		      	:= cOleMethod{}
	oMethod:symName	  	:= String2Symbol("GetCertificate")
	oMethod:iMemberid  	:= 116
	oMethod:wInvokeKind	:= INVOKE_METHOD
	oMethod:nParams    	:= 1
	oMethod:lNamedArgs 	:= TRUE
	oMethod:cParamTypes	:= VTS_I4
	oMethod:bRetType   	:= VT_DISPATCH

	uRetValue := SELF:__Invoke(oMethod, DWORD(_BP+16),PCount())
	// To use a pre-defined class here,
	// change OLEAutoObject to desired class name
	uRetValue := iif( uRetValue:pInterface != null_ptr , 
IChilkatCert{uRetValue}, null_object)


	RETURN (uRetValue)





Jamal

On 6/9/2021 7:24 AM, fernando moreno wrote:
> El jueves, 3 de junio de 2021 a las 19:53:16 UTC+2, Jamal escribió:
>> Hello Fernando!
>>
>> Chilkatsoft has free (no licene required) ActiveX and .NET versions of
>> their components: Cert, CertChain and CertStore which have methods and
>> properties to handle certificates.
>>
>> https://www.chilkatsoft.com/downloads.asp
>>
>> Jamal
>>
>>
>> Check the docs at:
>> On 5/31/2021 7:02 AM, fernando moreno wrote:
>>> Good evening:
>>>


>>> Does anyone know any library or sample to work with certificates? For example: extract signature, date of expiration and provide.
>>>
>>> Thanks for your atention
>>>
> Thanks you for your help.
> 
> Have you worked with these classes?
> 
> I have problems with the Init.
> 
> METHOD bGenerar2( ) CLASS Certificados
> local cTexto	as string
> local nElemento	:=1 as int
> local numCerts		:=0	as int
> local cert			:=''	as string
> local osCert   as Chilkat_9_5_0_CertStore_1
> local lReadOnly	:=true	as logic
> local success		:=true as logic
> 
> oscert:=Chilkat_9_5_0_CertStore_1{}
> success := oscert:OpenCurrentUserStore(lReadOnly)
> If !success
> 	AVISOS(self,"error",oscert:LastErrorText,true)
> 	return
> EndIf
> cTexto:=''
> numCerts:= oscert:NumCertificates_
> for nElemento:=i to numCerts
>      cert := oscert:GetCertificate(i)
>    cTexto	:=oscert:subjetDN+"   -    "+oscert:SubjectE+crlf
> next
> 
> self:oDCmCert:Value	:=cTexto
> return true
> 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Work with certificate fernando moreno <fmaplisoft@gmail.com> - 2021-05-31 04:02 -0700
  Re: Work with certificate Jamal <nospam@example.com> - 2021-06-03 13:53 -0400
    Re: Work with certificate fernando moreno <fmaplisoft@gmail.com> - 2021-06-09 04:24 -0700
      Re: Work with certificate Jamal <nospam@example.com> - 2021-06-10 04:04 -0400
        Re: Work with certificate fernando moreno <fmaplisoft@gmail.com> - 2021-06-17 04:04 -0700
          Re: Work with certificate Jamal <nospam@example.com> - 2021-06-17 11:42 -0400

csiph-web