編集

Sign an app package file

Code signing is a common practice for many applications. It's the process of digitally signing a file to verify the author and that the file hasn't been tampered with since it was signed. The signature of the app package file is verified during the publishing of the extension using the Publish-NAVApp cmdlet. For more technical information on signing, see Authenticode.

Note

If you want to publish an unsigned extension package in your on-premises environment, you need to explicitly state it by using the -SkipVerification parameter on the Publish-NAVApp cmdlet. An extension without a valid signature won't be published on Marketplace.

Choose a signing method that your certificate provider supports. Since June 1, 2023, publicly trusted code-signing certificates require hardware-protected private keys. The hardware must meet at least FIPS 140-2 Level 2 or Common Criteria EAL 4+ requirements. These requirements apply to the private key, not the public certificate file. Learn more in the CA/Browser Forum code-signing requirements.

For a certificate whose private key is protected in Azure Key Vault, follow Sign an app package file with Azure Key Vault. Use Sign an app package file with a PFX file only when your provider supplies a suitable exportable certificate and private key, such as a test certificate. Don't assume that a hardware-protected private key can be exported to a PFX file.

Sign an app package file with Azure Key Vault

Prerequisites

Use a supported Windows x64 signing environment for Business Central .app packages. Install the Microsoft Visual C++ 14 runtime. Then configure Azure Key Vault for code signing:

  1. (Optional) Setting up a service principal: If the signing operation should be done by a Service Principal, create a Service Principal in Azure.

  2. Azure Key Vault setup: Create an Azure Key Vault for your code-signing certificate if you don't already have one.

  3. Configure access policies: If the vault uses access policies, configure an Azure Key Vault access policy for the account used for signing. At minimum, the account needs the following permissions:

    • Key Management Operations: Get
    • Cryptographic Operations: Sign
    • Certificate Management Operations: Get

    The following image illustrates Sign and certificate Get. Also select key Get as listed above.

    Shows key Sign and certificate Get permissions in Azure Key Vault.

  4. Create or import your certificate: Follow your certificate authority's process for code signing with Azure Key Vault. Use an RSA-HSM key so that the private key remains hardware-protected. Key Vault supports certificate authority integration with DigiCert and GlobalSign, but confirm that your provider supports the required code-signing certificate through that integration.

If the vault uses Azure role-based access control instead of access policies, assign the signing account the Key Vault Reader and Key Vault Crypto User roles. Learn more in Azure Key Vault RBAC guide.

Note

Use the Premium SKU of Azure Key Vault for HSM-backed code-signing keys. Learn more about the signing environment, permissions, and key requirements in Sign CLI prerequisites and best practices.

Steps for signing your .app file with Azure Key Vault

  1. Install the .NET 10 SDK.

  2. Install the .NET Signing Tool by running the following command:

    dotnet tool install sign --global --prerelease
    
  3. Sign your apps by running one of the following commands:

    Signing with a managed identity:

    sign code azure-key-vault --azure-key-vault-url "https://MyKeyvault.vault.azure.net/" `
                              --azure-key-vault-certificate "NameOfMyCertificate" `
                              --azure-credential-type managed-identity `
                              --description "Some Description" `
                              --description-url "https://www.contoso.com/apps" `
                              --verbosity Information `
                              "C:\Apps\Proseware.app"
    

    Signing with the legacy service-principal options:

    These options remain supported but are deprecated by Sign CLI. Don't store a real client secret in a script or source control. For new automation, prefer the managed-identity example where available.

    sign code azure-key-vault --azure-key-vault-url "https://MyKeyvault.vault.azure.net/" `
                              --azure-key-vault-certificate "NameOfMyCertificate" `
                              --azure-key-vault-client-id "00001111-aaaa-2222-bbbb-3333cccc4444" `
                              --azure-key-vault-client-secret "Aa1Bb~2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_Jj0Kk1Ll2" `
                              --azure-key-vault-tenant-id "aaaabbbb-0000-cccc-1111-dddd2222eeee" `
                              --description "Some Description" `
                              --description-url "https://www.contoso.com/apps" `
                              --verbosity Information `
                              "C:\Apps\Proseware.app"
    

    For help with using the signing tool:

    sign code azure-key-vault --help
    

Sign an app package file with a PFX file

The signing of an app package file must be performed on a computer that has Dynamics 365 Business Central installed. If you're running Dynamics 365 Business Central on Docker for your development environment, that environment meets this requirement. You must also have the certificate that is used for signing on the computer. The certificate must include code signing as the intended purpose. It's recommended that you use a certificate purchased from a third-party certificate authority.

To start the Certificate Manager tool, press Win+R to open up the Run dialog box. At the prompt, type Certmgr.msc and then press Enter. This opens the Certificate Manager. Inspect the Trusted Root Certification Authorities folder.

Steps for signing your .app file with a PFX file

  1. Make sure that you sign the .app file on a Microsoft Windows computer that has Dynamics 365 Business Central installed.

  2. Copy your provider-supplied PFX file, including its exportable private key, to the signing computer. If necessary, follow your provider's instructions to create the PFX file. The example uses C:\Certificates\MyCert.pfx. Don't attempt to export a nonexportable hardware-protected private key. For local testing or development, you can instead create a self-signed certificate.

  3. Install a signing tool such as SignTool or SignCode to the computer. The sample command will use SignTool.

  4. Copy your extensions .app file to the computer if it's not already on the computer. The file path for the sample command is C:\NAV\Proseware.app.

  5. Run the following command to sign Proseware.app with a time stamp using the password-protected MyCert.pfx file.

    SignTool sign /f C:\Certificates\MyCert.pfx /p "<PfxPassword>" /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 "C:\NAV\Proseware.app"
    

    Use the signed app package when publishing the extension.

Important

We recommend using a time stamp when signing the app package file. A time stamp allows the signature to be verifiable even after the signing certificate has expired. Use the time-stamp service specified by your certificate authority. Learn more in Time stamping Authenticode signatures.

Note

If you are using the BCContainerHelper PowerShell module to run Dynamics 365 Business Central on Docker, you can use the function Sign-BCContainerApp to perform all the steps above.

Self-signed certificate

For testing purposes and on-premises deployments, you can create your own self-signed certificate by using the New-SelfSignedCertificate cmdlet in a supported Windows environment. A self-signed certificate isn't suitable for Marketplace submission.

The following example illustrates how to create a new self-signed certificate for code signing:

New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=ProsewareTest"

The following deprecated MakeCert example is retained for legacy environments. Use New-SelfSignedCertificate for new code-signing test certificates.

Makecert -sk myNewKey -n "CN=Prosewaretest" -r -ss my

Code signing for Marketplace

If you publish the extension as an app on Marketplace, the app package file must be signed using a certificate purchased from a certificate authority (CA). A self-signed certificate won't be accepted by technical validation. The CA must have its root certificates in Microsoft Windows. Choose a provider that meets these requirements and supports your signing method. You don't have to use an EV code-signing certificate; standard code-signing certificates can be used.

Check the signature on a Windows device configured to recognize Business Central .app packages that wasn't used to sign the file. Open the file's context menu and select Properties > Digital Signatures > Details. Select View Certificate > Certification Path. If the path has only one entry, check whether the certificate is self-signed. A self-signed certificate doesn't meet the Marketplace requirement, even if it's trusted on your signing computer.

Use SignTool to verify the signature and certificate chain rather than relying only on the number of entries in the path:

SignTool verify /pa /v "C:\NAV\Proseware.app"

Get started with AL
Keyboard shortcuts
AL development environment
Questions about code-signing validation