Bring Your Own Key — 10 Providers
All providers implement the IsgcKeyProvider interface — the same signing code works against local files, smart cards, HSMs, cloud KMS, or remote QTSPs. Switch with one line.
All providers implement the IsgcKeyProvider interface — the same signing code works against local files, smart cards, HSMs, cloud KMS, or remote QTSPs. Switch with one line.
TsgcPFXKeyProviderPFX / PKCS#12 files. Local password-protected key. Best for development, small deployments, and any workflow where the certificate ships as a single .pfx/.p12 file.
PKCS12_PREFER_CNG_KSP — SHA-256/384/512 signing works regardless of the original CSP.
.pfx files are walked automatically until the cert with the private key is found.
var
vPFX: TsgcPFXKeyProvider;
begin
vPFX := TsgcPFXKeyProvider.Create(nil);
try
vPFX.FileName := 'certificate.pfx';
vPFX.Password := 'mypassword';
vPFX.LoadFromFile;
// vSigner.KeyProvider := vPFX;
finally
vPFX.Free;
end;
end;
TsgcPEMKeyProviderPEM files. Encrypted PKCS#8 with native PBES2 / PBKDF2 / AES-CBC support, plus the legacy RSA private-key DEK-Info format. Best for OpenSSL-based pipelines.
BEGIN CERTIFICATE, BEGIN RSA PRIVATE KEY, BEGIN PRIVATE KEY, BEGIN ENCRYPTED PRIVATE KEY all supported.
PrivateKeyFile empty.
var
vPEM: TsgcPEMKeyProvider;
begin
vPEM := TsgcPEMKeyProvider.Create(nil);
try
vPEM.CertificateFile := 'cert.pem';
vPEM.PrivateKeyFile := 'key.pem';
vPEM.PrivateKeyPassword := 'secret';
vPEM.LoadFromFile;
// vSigner.KeyProvider := vPEM;
finally
vPEM.Free;
end;
end;
TsgcWindowsCertStoreProviderWindows Certificate Store. Local-machine and current-user stores. Best for desktop apps using existing AD-issued certificates, or any deployment where Windows already manages the cert lifecycle.
var
vStore: TsgcWindowsCertStoreProvider;
begin
vStore := TsgcWindowsCertStoreProvider.Create(nil);
try
vStore.StoreName := 'MY';
vStore.StoreLocation := cslCurrentUser;
vStore.SelectCertificateBySubject('My Company');
// vSigner.KeyProvider := vStore;
finally
vStore.Free;
end;
end;
TsgcPKCS11ProviderPKCS#11 / Hardware Tokens. Smart cards, USB tokens, HSMs — SafeNet, YubiKey, Nitrokey, Thales. Required for Qualified Electronic Signatures in most EU jurisdictions.
CKM_RSA_PKCS and CKM_ECDSA_SHA256 mechanisms supported.
EnumerateSlots / EnumerateCertificates helpers for picking the right slot at runtime.
var
vTok: TsgcPKCS11Provider;
begin
vTok := TsgcPKCS11Provider.Create(nil);
try
vTok.LibraryPath := 'C:\token\pkcs11.dll';
vTok.SlotIndex := 0;
vTok.PIN := '1234';
vTok.CertificateLabel := 'MyCert';
vTok.Connect;
// vSigner.KeyProvider := vTok;
finally
vTok.Free;
end;
end;
TsgcAzureTrustedSigningProviderAzure Trusted Signing. Microsoft's qualified code-signing service. Authenticode without buying an EV cert — Microsoft owns the certificate and provisions the signing key for you.
var
vAzure: TsgcAzureTrustedSigningProvider;
begin
vAzure := TsgcAzureTrustedSigningProvider.Create(nil);
try
vAzure.TenantId := 'your-tenant-id';
vAzure.ClientId := 'your-client-id';
vAzure.ClientSecret := 'your-client-secret';
vAzure.AccountName := 'mySigningAccount';
vAzure.CertificateProfileName := 'default';
vAzure.Connect;
// vSigner.KeyProvider := vAzure;
finally
vAzure.Free;
end;
end;
TsgcAWSKMSKeyProviderAWS Key Management Service. Amazon's HSM-backed key custody service. Pair with an AWS-issued cert for in-cloud signing without exposing the private key.
KeyId accepts key ID, key ARN, or alias ARN.
var
vAWS: TsgcAWSKMSKeyProvider;
begin
vAWS := TsgcAWSKMSKeyProvider.Create(nil);
try
vAWS.AccessKeyId := 'AKIAIOSFODNN7EXAMPLE';
vAWS.SecretAccessKey := 'wJalrXUtnFEMI/K7MDENG/...';
vAWS.Region := 'us-east-1';
vAWS.KeyId := 'arn:aws:kms:us-east-1:...:key/my-key';
vAWS.Connect;
// vSigner.KeyProvider := vAWS;
finally
vAWS.Free;
end;
end;
TsgcGCloudKMSKeyProviderGoogle Cloud KMS. Same operational model as AWS KMS. Service-account JSON file authenticates via JWT exchange to OAuth2 access token, then signs through the Cloud KMS API.
var
vGCloud: TsgcGCloudKMSKeyProvider;
begin
vGCloud := TsgcGCloudKMSKeyProvider.Create(nil);
try
vGCloud.ProjectId := 'my-project';
vGCloud.LocationId := 'global';
vGCloud.KeyRingId := 'my-key-ring';
vGCloud.KeyId := 'my-signing-key';
vGCloud.KeyVersion := '1';
vGCloud.ServiceAccountJSON := 'C:\keys\sa.json';
vGCloud.Connect;
// vSigner.KeyProvider := vGCloud;
finally
vGCloud.Free;
end;
end;
TsgcHashiCorpVaultKeyProviderHashiCorp Vault. Vault's Transit secrets engine performs the signing. Best for self-hosted, policy-driven key custody where Vault is already part of the stack.
SetCertificateFromFile.
'transit'.
var
vVault: TsgcHashiCorpVaultKeyProvider;
begin
vVault := TsgcHashiCorpVaultKeyProvider.Create(nil);
try
vVault.VaultAddress := 'https://vault.example.com:8200';
vVault.Token := 's.myVaultToken';
vVault.MountPath := 'transit';
vVault.KeyName := 'my-signing-key';
vVault.Connect;
vVault.SetCertificateFromFile('C:\certs\signing-cert.pem');
// vSigner.KeyProvider := vVault;
finally
vVault.Free;
end;
end;
TsgcCertumSimplySignProviderCertum SimplySign. Polish QTSP. Qualified electronic signatures via mobile-app-authorised PIN, no USB token required. Common choice for Polish KSeF and ZUS workflows.
ListCertificates exposes every cert available in the account.
var
vCertum: TsgcCertumSimplySignProvider;
begin
vCertum := TsgcCertumSimplySignProvider.Create(nil);
try
vCertum.ClientId := 'your-client-id';
vCertum.ClientSecret := 'your-client-secret';
vCertum.Username := 'user@example.com';
vCertum.Password := 'account-password';
vCertum.PIN := '123456';
vCertum.BaseURL := 'https://cloudsign.certum.pl';
vCertum.Connect;
// vSigner.KeyProvider := vCertum;
finally
vCertum.Free;
end;
end;
TsgcCSCKeyProviderCloud Signature Consortium API v2. Generic interface to any QTSP that implements CSC v2 — Universign, D-Trust sign-me, A-Trust, FNMT Cl@ve Firma, Evrotrust, Intesi Group. The provider holds the qualified key in a remote QSCD; sgcSign sends only the document hash.
cscBasic, cscOAuth2, cscOTP (one-time password for two-factor).
credentials/authorize + signatures/signHash per CSC v2 spec.
var
vCSC: TsgcCSCKeyProvider;
vCreds: TStringArray;
begin
vCSC := TsgcCSCKeyProvider.Create(nil);
try
vCSC.BaseURL := 'https://api.qtsp.example/csc/v2';
vCSC.AuthMethod := cscBasic;
vCSC.Username := 'alice';
vCSC.Password := 'secret';
vCreds := vCSC.ListCredentials;
vCSC.CredentialID := vCreds[0];
vCSC.PIN := '123456';
vCSC.OTP := '987654';
vCSC.LoadCredentialInfo;
// vSigner.KeyProvider := vCSC;
finally
vCSC.Free;
end;
end;
Every provider implements IsgcKeyProvider. The signer code never knows whether the key lives on disk, on a token, in Azure, or behind a CSC v2 API.
function SignWithAnyProvider(
aProvider: IsgcKeyProvider; const aXML: string): string;
var
vSigner: TsgcXAdESSigner;
begin
vSigner := TsgcXAdESSigner.Create(nil);
try
vSigner.KeyProvider := aProvider;
vSigner.Profile.LoadProfile(spEmploymentDE);
Result := vSigner.SignXML(aXML);
finally
vSigner.Free;
end;
end;
// Caller picks the provider; signer doesn't care.
SignWithAnyProvider(vPFX, vXML);
SignWithAnyProvider(vAzure, vXML);
SignWithAnyProvider(vCSC, vXML);