Signing a Windows Service Executable During CI Builds with OneSigner

Nov 30, 2026 · Tutorials · 14 views

Automating Windows Authenticode code signing for compiled service executables during continuous integration builds requires keeping your private keys secure on certified hardware without breaking unattended pipelines. This guide shows you how to connect your build agents to a dedicated OneSigner host using the Azure Key Vault-compatible endpoint so your build scripts can sign files without manual intervention.

Understanding the Architecture for CI Code Signing

Code signing certificates issued for Organization Validation (OV) and Extended Validation (EV) must reside on certified hardware tokens—such as a YubiKey, SafeNet eToken, or ePass2003—according to CA/Browser Forum rules. Because these USB devices must physically plug into a machine, you cannot place the private key directly onto a cloud-hosted build agent.

OneSigner solves this by running as a Windows service on a local machine where your hardware token is attached. It exposes an Azure Key Vault-compatible endpoint on port 9440 by default, allowing standard client tools like AzureSignTool or OneSignTool to submit file hashes over the network. The build agent sends only the cryptographic hash of your compiled Windows service executable; the file itself never leaves your build environment, and the private key never leaves the physical token.

Setting Up the OneSigner Host and AzureSignTool Proxy

Before configuring your CI pipeline, ensure your physical signing machine is properly prepared. The machine must remain powered on with the hardware token plugged into a USB port. OneSigner runs as the OneSignerService under LocalSystem and bridges interactive token access by starting signing operations in the logged-on user's session. To ensure unattended operation after reboots, open the OneSigner configuration GUI, navigate to the General tab, and enable the Auto-Logon option. Note that Windows stores this password in plain text within the Winlogon registry key.

The service listens for AzureSignTool-compatible requests out of the box. You will need three pieces of information from your OneSigner installation to configure your CI agent:

  • OneSigner URL: The base HTTPS URL or local IP address pointing to port 9440 (e.g., https://signing-host.internal:9440).
  • Tenant Token: The Bearer token generated in your OneSigner configuration for authenticating requests.
  • Certificate Name: The friendly name or subject common name of the signing certificate present on your attached hardware token.

Configuring Your CI Pipeline and Build Scripts

Once your signing host is running, configure your CI/CD runner—whether running on GitHub Actions, GitLab CI, Jenkins, or Azure DevOps—to invoke AzureSignTool or OneSignTool immediately after compiling your Windows service executable. Because these tools emulate the Azure Key Vault REST protocol, they accept standard command-line flags to target your self-hosted OneSigner instance.

Store your OneSigner tenant token as a secure secret variable in your CI environment (for example, as ONESIGNER_TOKEN). Never hardcode tokens or credentials directly into your build scripts or source repository. Below is a practical command example showing how to execute the signing step within a PowerShell build script:

azure-sign-tool sign \
  -kvu "https://signing-host.internal:9440" \
  -kva "$env:ONESIGNER_TOKEN" \
  -kvc "YourOrganizationCodeSigningCert" \
  -tr "http://timestamp.digicert.com" \
  -td "sha256" \
  "C:\Builds\Output\MyWindowsService.exe"

This command instructs AzureSignTool to calculate the Authenticode hash of MyWindowsService.exe locally on the build agent, transmit that hash securely to your OneSigner service, apply the hardware-backed signature, and embed a trusted RFC 3161 timestamp from your preferred timestamp authority.

Handling Common Troubleshooting Scenarios

Automated signing environments can occasionally encounter operational friction. If your CI build fails during the signing phase, examine the logs located on the OneSigner host at C:\OneSigner\app\logs\signing-YYYY-MM-DD.log, which record tab-separated execution history, or check the Windows Application Event Log under the OneSignerService source.

One critical edge case involves token PIN management. OneSigner caches and automates the PIN entry through PKCS#11 or CSP/KSP drivers to prevent interactive dialog blocks. However, a rejected PIN is not retried automatically within the same job to protect your hardware token from getting locked out after successive failures. Furthermore, if you update the PIN directly on your physical token, you must remember to update the saved PIN inside your OneSigner profile. Otherwise, stale saved credentials will cause subsequent jobs to fail, and over multiple automated runs, can still result in a locked token.

Additionally, ensure your network firewalls permit traffic on port 9440 between your build agents and the designated OneSigner machine. If you are exposing the service externally for distributed build nodes, secure the endpoint using a built-in Cloudflare tunnel configured to your own domain or a onesign.sg subdomain rather than exposing raw HTTP ports to the public internet.

Next Steps and Production Deployment

With your build pipeline successfully communicating with your hardware-backed signing host, your Windows service executables will be signed consistently on every release commit. To expand your deployment across multiple tenants or increase user limits for your team, review the available options on the OneSigner license plans page. If you need assistance acquiring or renewing hardware-backed certificates to populate your USB tokens, check out the OneSigner certificate catalog to pair your software installation with trusted CA products.

Related Posts