TrFile_GetCodeSignInfo (function reference)

Troi File Plug-in > Functions reference > TrFile_GetCodeSignInfo
Troi File Plug-in for FileMaker Pro

TrFile_GetCodeSignInfo

Gets code sign information of a (application) file or checks if the signing is valid

SyntaxFunction badge

TrFile_GetCodeSignInfo ( switches ; filePath )

Parameters

switchesmodifies the behavior of the function
filePaththe path to the (application) file to be checked

Switches

Switches can be empty or one of this:

-GetGeneralInfo(default) returns a list of general information of the certificate used to sign the file
-HasValidCodeSignreturns 1 if this file has a valid code sign and 0 (zero) otherwise
-GetSubjectNamereturns the subject name of the certificate (like the company or organization)
-GetPublicKeyreturns the public key

Returned Result

Data type returned

Text

Result

The returned result depends on the switch used. See above and the examples below.

If an error occurs it will start with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

$$-43fnfErrthe file could not be found
$$-120dirNFErrdirectory not found

Other errors may be returned.

Originated in

Troi File Plug-in 10.0

Compatibility

FileMaker Pro 13 to 17

Example

TrFile_GetCodeSignInfo ( "-HasValidCodeSign" ; 
		"C:\Program Files\FileMaker\FileMaker Pro 16 Advanced\FileMaker Pro Advanced.exe" )

This will return 1 if the executable is valid, 0 if it has an invalid signing. The result can also be an error code, starting with $$.

Example 2

We assume that in your FileMaker file the following fields are defined:

  gErrorCode		Global, number
  gSourceFilePath	Global, text
  gCodeSignInfo		Global, text

gSourceFilePath should contain the path to an existing file, for example “D:\Acme_Plugin.fmx64” (Windows) or “Mac HD:Acme.fmplugin” (Mac). In a script add the following script steps:

Set Variable [ $FilePath ; gSourceFilePath  // store the path in a variable ]
Set Variable [ $Result ; TrFile_GetCodeSignInfo ( "-GetGeneralInfo" ; $FilePath ) ]
If [ Left ( $Result ; 2 ) = "$$" // there is an error ]
	Set Variable [ $ErrorCode ; $Result ]
	Set Field [ gCodeSignInfo ; "" // clear ]
Else
	Set Field [ gCodeSignInfo ; $Result ]
End If

This will put the code sign info into the field, and will be similar to this:

Name: Acme Software Corp.
Issued by: Apple Certification Authority
Sign status: Signed with a valid certificate

If the code signing is incorrect the result will be:

Sign status: Invalid, incorrectly signed.

If the file is not signed at all the result will be:

Sign status: Not signed, no code signing information found.

Related functionsFunction badge

TrFile_DeleteFile
TrFile_GetFileHash
TrFile_Launch

Related script stepsScript step badge

Delete File
Launch Application

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 13 to 17 –> TrFile_GetCodeSignInfo (filep4318) 2018-0515 14:38:59