CodeSign Tcl Reference Documentation
CodeSign
Current Version: 10.1.2
A class for signing Windows executables and DLLs, and for verifying signed executables and DLLs. This is a Windows-only class. The class and functions will exist on non-Windows systems, but will be no-op functions (stubs) that simply return a failed status.
Object Creation
set myCodeSign [new CkCodeSign]
Properties
DebugLogFilePath
# ckStr is a CkString
CkCodeSign_get_DebugLogFilePath $myCodeSign $ckStr
set strVal [CkCodeSign_get_debugLogFilePath $myCodeSign]
CkCodeSign_put_DebugLogFilePath $myCodeSign $strVal
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
LastErrorHtml
# ckStr is a CkString
CkCodeSign_get_LastErrorHtml $myCodeSign $ckStr
set strVal [CkCodeSign_get_lastErrorHtml $myCodeSign]
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
# ckStr is a CkString
CkCodeSign_get_LastErrorText $myCodeSign $ckStr
set strVal [CkCodeSign_get_lastErrorText $myCodeSign]
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
# ckStr is a CkString
CkCodeSign_get_LastErrorXml $myCodeSign $ckStr
set strVal [CkCodeSign_get_lastErrorXml $myCodeSign]
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
set boolVal [CkCodeSign_get_LastMethodSuccess $myCodeSign]
CkCodeSign_put_LastMethodSuccess $myCodeSign $boolVal
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages.
topUncommonOptions
# ckStr is a CkString
CkCodeSign_get_UncommonOptions $myCodeSign $ckStr
set strVal [CkCodeSign_get_uncommonOptions $myCodeSign]
CkCodeSign_put_UncommonOptions $myCodeSign $strVal
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.
Can be set to a list of the following comma separated keywords:
- "codesign-allow-expired-cert" - Don't fail authenticode signature validation because the signing certificate is expired.
Utf8
set boolVal [CkCodeSign_get_Utf8 $myCodeSign]
CkCodeSign_put_Utf8 $myCodeSign $boolVal
When set to 1, all "const char *" arguments are interpreted as utf-8 strings. If set to 0 (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to 1, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to 0, all "const char *" return values are ANSI strings.
topVerboseLogging
set boolVal [CkCodeSign_get_VerboseLogging $myCodeSign]
CkCodeSign_put_VerboseLogging $myCodeSign $boolVal
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
topVersion
# ckStr is a CkString
CkCodeSign_get_Version $myCodeSign $ckStr
set strVal [CkCodeSign_get_version $myCodeSign]
Methods
AddSignature
# cert is a CkCert
# options is a CkJsonObject
set status [CkCodeSign_AddSignature $path $cert $options]
Authenticode signs a DLL or EXE.
Returns 1 for success, 0 for failure.
AddSignatureAsync (1)
# path is a string
# cert is a CkCert
# options is a CkJsonObject
set ret_task [CkCodeSign_AddSignatureAsync $path $cert $options]
Creates an asynchronous task to call the AddSignature method with the arguments provided.
Returns NULL on failure
topGetSignerCert
set status [CkCodeSign_GetSignerCert $cert]
This method retrieves the signer certificate after calling VerifySignature. If successful and the signer certificate is fully available, cert will contain the certificate.
Returns 1 for success, 0 for failure.
topRemoveSignature
set status [CkCodeSign_RemoveSignature $path]
Removes the authenticode signature of a Windows executable or DLL. The path to the executable/DLL is passed in path.
Returns 1 for success, 0 for failure.
VerifySignature
# sigInfo is a CkJsonObject
set status [CkCodeSign_VerifySignature $path $sigInfo]
Verifies the signature of a Windows executable or DLL. The path to the executable/DLL is passed in path. Information about the signature is returned in sigInfo. Returns 1 if the signature is verified indicating the EXE or DLL can be trusted. Otherwise returns 0.
Returns 1 for success, 0 for failure.