I'd like to display in a control whether an EXE file is digitally signed. I've tried the following, but it doesn't work dlg.Control("firma").label = item.metadata.signer || "";
I know there's a column (Signed By) that displays this value, but would it be possible to extract this value directly from the column, or is there a simpler way? Thanks.
@Leo, I've created a small script that displays information of interest to me, depending on the type of file selected. When I select a digitally signed EXE file, the script doesn't display any information in the field: dlg.Control("firma").label = item.metadata.exe.signer || ""; when it should display X information. I'll leave the script here in case you'd like to try it.
Thanks. I see the problem. The item.metadata.exe object will only give useful information for things like Signer if the item object already has that data cached. It's only really useful when reading data from a file display that's already showing those columns and has populated them.
(This is because it can be quite expensive to calculate the signature details, and currently would have to be calculated when the object is first created, where we don't know if that data is going to be used or not yet. That's more down to the design of things on our side than anything else.)
I've added a note to the exe metadata object's docs about that.
var filepath = DOpus.FSUtil.Resolve("/home/dopus.exe");
var item = DOpus.FSUtil.GetItem(filepath);
DOpus.Output("Met Path: " + item);
DOpus.Output("Met Name: " + item.metadata.exe.prodname);
DOpus.Output("Met Sign: " + item.metadata.exe.signer);
DOpus.Output("");
var sig = DOpus.FSUtil.GetSignature(filepath, true);
DOpus.Output("Sig Valid: " + sig.valid);
DOpus.Output("Sig Sign: " + sig.certsigner.subject);
Outputs:
Met Path: C:\Program Files\GPSoftware\Directory Opus\dopus.exe
Met Name: Directory Opus
Met Sign: undefined
Sig Valid: true
Sig Sign: GP Software (Redbrook Pty Ltd)
If you just want to know who signed the file, without verifying that the signature is actually valid, you can make it faster by changing the GetSignature call to pass false instead of true as the 2nd argument. But then the signature may be bogus as the file may have been modified after it was signed, or the signature itself may be fake.
There are also other flags you can pass GetSignature to change how many checks it does (e.g. checking for certificate revocation may be important, but adds further delay before the result).