Delphi, C++ Builder and .NET Library and signing server

Azure Trusted Signing from Delphi, .NET and CI/CD

Sign Windows applications with Azure Trusted Signing from Delphi or .NET.

Authenticode-sign EXE and DLL files
Private key stays in Azure
No local PFX, no USB token
Build agents sign without Azure secrets
TsgcAzureTrustedSigningProviderOAuth2 client credentialsMicrosoft-issued public-trust certificateRemote signing server

Sign from a CI pipeline → · See pricing →

SignWithAzure.pas
// Authenticode-sign with Azure Trusted Signing
var
  vKeyProvider: TsgcAzureTrustedSigningProvider;
  vSigner: TsgcAuthenticodeSigner;
begin
  vKeyProvider := TsgcAzureTrustedSigningProvider.Create(nil);
  vSigner := TsgcAuthenticodeSigner.Create(nil);
  try
    vKeyProvider.TenantId := '00000000-0000-0000-0000-000000000000';
    vKeyProvider.ClientId := '11111111-1111-1111-1111-111111111111';
    vKeyProvider.ClientSecret := 'my-client-secret';
    vKeyProvider.AccountName := 'my-trusted-signing-account';
    vKeyProvider.CertificateProfileName := 'public-trust';
    vKeyProvider.Endpoint := 'https://eus.codesigning.azure.net';
    vKeyProvider.Connect;

    vSigner.KeyProvider := vKeyProvider;
    vSigner.Level := alBES;   // alT additionally requires a TSAClient
    vSigner.SignFile('myapp.exe', 'myapp-signed.exe');
  finally
    vSigner.Free;
    vKeyProvider.Free;
  end;
end;

How sgcSign Uses Azure Trusted Signing

Sign Windows applications with Azure Trusted Signing from your own Delphi or .NET code, or from any CI pipeline through the sgcSign Server, while the private key stays in Azure.

One key provider, three places to sign from: your Delphi application, your .NET code, or the build pipeline through the signing server.

Azure Trusted Signing (formerly Azure Code Signing) is Microsoft's code signing service. Microsoft owns the certificate and provisions the signing key for you, and the private key lives entirely in Azure. sgcSign talks to it through TsgcAzureTrustedSigningProvider, which authenticates with OAuth2 client credentials.

Every sgcSign key provider implements IsgcKeyProvider, so the signing code does not care where the key lives. Develop with a local PFX, test with the Windows certificate store, and release with Azure Trusted Signing by swapping one provider. The other options are listed on the key providers page.

From Delphi and C++ Builder

TsgcAuthenticodeSigner takes the Azure provider as its KeyProvider and signs .exe, .dll, .sys, .ocx, .cpl and .scr files in process, on Windows, with no external signing tool.

From .NET

The esegece.sgcSign NuGet package has the same TsgcAzureTrustedSigningProvider class with the same properties, assigned to a signer's KeyProvider in C#.

From CI/CD

The sgcSign Server holds the Azure credentials as an AzureTS provider. Build agents sign over HTTPS with an API key and never see the tenant, client or secret.

What You Configure

Three steps in the Azure portal, then the provider values in sgcSign. The same values feed the Delphi and .NET provider and the server configuration.

From Azure account to first signature

  1. Create an Azure Trusted Signing account in the Azure portal.
  2. Create a certificate profile and note the profile name.
  3. Register an Azure AD application and grant it the Trusted Signing Certificate Profile Signer role.
  4. Configure the provider with the tenant ID, client ID, client secret, account name and certificate profile name. Endpoint sets the signing endpoint URL of your account.

Call Connect on the provider before signing. In the server, the client secret can come from an environment variable, so it is never written to the configuration file.

settings.txt
Delphi / .NET property     Server param (AzureTS)
TenantId                   tenant_id
ClientId                   client_id
ClientSecret               client_secret_env
AccountName                account
CertificateProfileName     certificate_profile
Endpoint                   endpoint

Authenticode Options in Delphi

The code in the hero above is the whole job. These properties of TsgcAuthenticodeSigner shape the signature it produces.

Timestamped signatures

Level is alT by default, which adds an RFC 3161 timestamp through a TsgcTSAClient assigned to TSAClient. alBES signs without one.

Hash and publisher details

Hash defaults to ahSHA256. Description and URL embed the program name and a more information link in the signature.

Dual signatures

Set AppendSignature to True to add a nested signature to a file that is already signed, for example SHA-1 for old Windows and SHA-256 for current Windows.

Files, streams and memory

SignFile reads and writes files, SignStream works on streams and SignBytes signs a binary held in memory.

The Same Provider in C#

The .NET library keeps the Delphi names, so a team that signs from both languages configures Azure Trusted Signing once.

Install, configure, assign

  • Add the registered package with dotnet add package esegece.sgcSign.
  • Set the tenant, client, secret, account and certificate profile on TsgcAzureTrustedSigningProvider.
  • Assign it to the signer's KeyProvider, exactly as in Delphi.
  • NuGet packages, ClickOnce manifests and VSIX extensions are signed by the sgcSign Server with the same Azure provider.
AzureProvider.cs
var azure = new TsgcAzureTrustedSigningProvider();
azure.TenantId = "your-tenant-id";
azure.ClientId = "your-client-id";
azure.ClientSecret = "your-client-secret";
azure.AccountName = "your-account-name";
azure.CertificateProfileName = "your-profile";

// Assign it to the KeyProvider of an sgcSign signer
signer.KeyProvider = azure;

Sign From a CI Pipeline With Azure Trusted Signing

Put the Azure credentials on one sgcSign Server instead of every build agent. Runners hold an API key and sign over HTTPS.

One provider entry, every runner

  • Add an AzureTS provider to sgcSignServer.conf.json. Any parameter ending in _env is read from an environment variable, so the client secret stays out of the file.
  • sgcSignServer --selftest-providers loads the configuration, initialises every provider and exits, so you can check the Azure values before going live.
  • The sgcsign client hashes the executable on the runner and sends only the hash. The server signs it with Azure Trusted Signing and the client embeds the signature.
  • API keys per project, optional approvals and a hash-chained audit log record who signed what with the Azure profile.
sgcSignServer.conf.json
"providers": [
  {
    "name": "release",
    "type": "AzureTS",
    "params": {
      "tenant_id": "00000000-0000-0000-0000-000000000000",
      "client_id": "00000000-0000-0000-0000-000000000000",
      "client_secret_env": "SGCSIGN_AZURE_TS_SECRET",
      "account": "your-account",
      "certificate_profile": "your-profile",
      "endpoint": "https://eus.codesigning.azure.net/"
    }
  }
]

rem On the build agent
set SGCSIGN_SERVER=https://sign.example.com:8443
set SGCSIGN_APIKEY=%SIGNING_API_KEY%
sgcsign sign -f authenticode -p release -o MyApp-signed.exe MyApp.exe

See sgcSign in Two Minutes

Code and document signing from Delphi and .NET, with the same key provider model the Azure provider plugs into.

Sign code and documents from Delphi and .NET: PAdES, XAdES, CAdES and Authenticode, with smart cards and HSMs.

Frequently Asked Questions

Create a TsgcAzureTrustedSigningProvider, set TenantId, ClientId, ClientSecret, AccountName, CertificateProfileName and Endpoint, and call Connect. Assign it to the KeyProvider of a TsgcAuthenticodeSigner and call SignFile with the input and output paths. The sample at the top of this page is complete.

Yes. Configure an AzureTS provider on the sgcSign Server and give each runner an API key. The runner calls sgcsign sign or the REST API, the server signs with Azure Trusted Signing, and the Azure client secret never reaches the build agent.

Yes, through the sgcSign Server. It signs .exe and .dll files with Authenticode, .nupkg packages at POST /api/v1/sign/nuget, ClickOnce manifests and VSIX extensions, all with the key provider you configure, Azure Trusted Signing included. In your own .NET code, the esegece.sgcSign package offers the same Azure provider class.

No. With Azure Trusted Signing, Microsoft owns the certificate and provisions the signing key, and the private key lives entirely in Azure. sgcSign signs with it through OAuth2 client credentials, so no certificate or key file sits on the build machine.

An Azure Trusted Signing account, a certificate profile, and an Azure AD application with the Trusted Signing Certificate Profile Signer role. From these you take the tenant ID, the client ID, a client secret, the account name and the profile name. The setup section maps each value to the Delphi property and the server parameter.

Yes. In Delphi, set Level to alT and assign a TsgcTSAClient to TSAClient. The sgcSign Server keeps a list of default RFC 3161 timestamp servers and tries them in order until one answers, with per-provider tsa_urls lists when a provider needs its own.

Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Sign With Azure Trusted Signing Today

From a Delphi application, a .NET program or a build pipeline, with the private key kept in Azure.