Search code examples
vbacode-signingcode-signing-certificatesigntoolxlsm

SignTool: can't sign XLSM (DOCM)


I have a litte problem with Microsoft SignTool.exe. I have installed Windows 10 SDKs and Office SIPs to support macro enabled documents. Then I followed readme to activate dlls and made all the changes, including:

  1. Installed - Microsoft Visual C++ Runtime Libraries
  2. Set path to VBE7.DLL

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBA]
"Vbe71DllPath"="C:\Workspace\Signing\vbe7.dll"

  1. Registered MSOSIPX.DLL with REGSVR32
  2. I have also created wintrust.dll.ini and added:

[1]
DLL=<C:\Workspace\Signing\msosipx.dll>
GUID={6E64D5BD-CEB0-4B66-B4A0-15AC71775C48}
CryptSIPDllCreateIndirectData=_VBASipCreateIndirectData@12
CryptSIPDllGetSignedDataMsg=_VBASipGetSignedDataMsg@20
CryptSIPDllIsMyFileType2=_VBASipIsMyTypeOfFileName@8
CryptSIPDllPutSignedDataMsg=_VBASipPutSignedDataMsg@20
CryptSIPDllRemoveSignedDataMsg=_VBASipRemoveSignedDataMsg@8
CryptSIPDllVerifyIndirectData=_VBASipVerifyIndirectData@8

  1. I'm using:

    signtool sign /debug /n "Cert" /fd SHA256 test.xlsm and the following happens:

SignTool Error: This file format cannot be signed because it is not recognized.
SignTool Error: An error occurred while attempting to sign: test.xlsm
Number of files successfully Signed: 0
Number of warnings: 0
Number of errors: 1


Little note at the end:

With test.exe it worked just fine.


Solution

  • I have solved the problem by using regsvr32.exe via powershell instead of cmd.

    Important note! I'm calling regsvr32.exe on msosipx.dll in my working folder C:\Workspace\Signing.

    P.S. I don't really understand why it's working.