How to Digitally Sign a LibreOffice Macro

Digitally signing a macro script in LibreOffice ensures macro integrity, verifies the author’s identity, and allows scripts to run smoothly under strict macro security policies. This guide outlines the exact steps required to apply a digital signature to your macro code directly from the LibreOffice Basic Integrated Development Environment (IDE).

Prerequisites

Before signing a macro inside the LibreOffice IDE, you must have a valid personal digital certificate installed on your operating system: * Windows: The certificate must be installed in the Windows Certificate Store. * macOS: The certificate must be located in the macOS Keychain. * Linux: LibreOffice utilizes certificates stored in the Mozilla/Firefox Network Security Services (NSS) database. Configure your certificate directory under Tools > Options > LibreOffice > Security > Certificate Path.


Step-by-Step Signing Process

  1. Open the LibreOffice Basic IDE
    Open the LibreOffice document containing your macro code. In the main menu, navigate to Tools > Macros > Edit Macros (or press Alt + F11, select your macro, and click Edit).

  2. Open the Digital Signatures Dialog
    Inside the Basic IDE window, click File on the top menu bar and select Digital Signatures….

  3. Select Your Certificate
    In the Digital Signatures dialog box:

    • Click the Sign Document button.
    • A list of available digital certificates will appear. Select the certificate you wish to use for signing.
    • Click Sign (or OK).
  4. Verify the Signature
    The certificate will now appear in the Digital Signatures dialog list with details including the issuer, expiration date, and validity status. Click Close.

  5. Save the Document
    Return to the document or IDE and save your file (File > Save or Ctrl + S). The digital signature is stored directly within the document file alongside the macro code.


Verifying Macro Security Settings

For signed macros to execute without repeated security warnings, configure your security level:

  1. Go to Tools > Options > LibreOffice > Security.
  2. Click the Macro Security… button.
  3. Set the security level to Medium (prompts before running unsigned macros, executes signed macros) or High (only signed macros from trusted sources are executed).
  4. Under the Trusted Sources tab, you can add your certificate to the list of trusted certificates.