Configure SQL Server
Configure SQL Server
Set up Microsoft SQL Server to use the DuoKey EKM Provider for TDE
Overview
This guide explains how to configure Microsoft SQL Server to use the DuoKey EKM Provider for Transparent Data Encryption (TDE). Configuration has two parts: a one-time setup of the provider connection file on the host, and the SQL steps that enable EKM, register the provider, create a credential, and open the master key.
Provider Configuration File
Before running any SQL, complete the config.toml you deployed to C:\ProgramData\DKE\EKM\ during installation. It holds the connection settings the provider uses to reach the DuoKey platform.
# DuoKey endpoint
server_url = "https://<cockpit-host>"
# Provider identity assigned by DuoKey when the app was created
provider_guid = "<provider-guid>"
provider_name = "<provider-name>"
# Tenant and application identifiers from your SQL EKM App
tenant_id = "<tenant-id>"
app_id = "<app-id>"
# Provider-level authentication to the platform (single value)
api_key = "<api-key>"
# Optional: mutual TLS
# client_cert_path = "C:\\ProgramData\\DKE\\EKM\\client.pem"
# client_key_path = "C:\\ProgramData\\DKE\\EKM\\client.key"The api_key field authenticates the provider's own connection to the platform - it is required (together with, or instead of, mutual TLS) before the provider will start, and it authorizes optional log forwarding to the platform. It does not authorize individual encrypt/decrypt/wrap operations for TDE: every cryptographic call is authorized per SQL Server session using the agent key supplied through CREATE CREDENTIAL ... SECRET (see below). Keep both values secret, but do not assume setting one removes the need for the other.
Alongside config.toml, the provider maintains keystore.json in the same folder. It maps the SQL asymmetric key to the DuoKey key so that TDE-protected databases reopen automatically after a SQL Server service restart. Do not delete it while databases are encrypted.
Prerequisites
- SQL EKM App created in DuoKey platform
- EKM Provider library and config.toml deployed on the host
- Agent key from the SQL EKM app
- SQL Server Management Studio (SSMS) installed
- Sysadmin privileges on SQL Server
Configuration Steps
Enable EKM Provider Support
First, enable Extensible Key Management in SQL Server. Open SSMS and execute:
-- Enable advanced options
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
-- Enable EKM provider
sp_configure 'EKM provider enabled', 1;
GO
RECONFIGURE;
GOThis step is only required once per SQL Server instance.
Create the Cryptographic Provider
Register the DuoKey EKM Provider library from the folder where you deployed it.
CREATE CRYPTOGRAPHIC PROVIDER DkeEkm
FROM FILE = 'C:\Program Files\DKE\EKM\DuoKeyCryptoProvider.dll';
GOThe library must be code-signed with a chain trusted on this machine. If the signature is not trusted, this command fails and SQL Server will not load the provider. See the installation guide for verifying the signature.
Create the Provider Credential
Create a credential that carries the agent key the provider uses to authenticate with DuoKey.
CREATE CREDENTIAL DkeEkmCredential
WITH IDENTITY = 'DuoKey EKM',
SECRET = '<agent-key>'
FOR CRYPTOGRAPHIC PROVIDER DkeEkm;
GO| Parameter | Description |
|---|---|
IDENTITY | A free-text label for the credential. It is not validated against the platform. |
SECRET | The single agent-key value from your SQL EKM App. |
The SECRET is one value — the agent key. There is no client ID, client secret, or password to combine, and no delimiter format to follow.
Map the Credential to a Login
Map the credential to the login that will manage encrypted databases.
ALTER LOGIN [sa]
ADD CREDENTIAL DkeEkmCredential;
GOUse the login that administers TDE, typically a sysadmin account.
Open the TDE Master Key
The TDE master key lives in DuoKey. You open a reference to it from SQL Server rather than generating a new key locally.
Open the Existing Asymmetric Key
USE master;
CREATE ASYMMETRIC KEY TDE_Master
FROM PROVIDER DkeEkm
WITH PROVIDER_KEY_NAME = 'TDE_MASTER',
CREATION_DISPOSITION = OPEN_EXISTING;
GO| Parameter | Description |
|---|---|
PROVIDER_KEY_NAME | The name of the key in the DuoKey platform. |
CREATION_DISPOSITION | OPEN_EXISTING references the key already provisioned in DuoKey. |
Use CREATION_DISPOSITION = OPEN_EXISTING and do not specify WITH ALGORITHM. The master key is provisioned in DuoKey; SQL Server only opens a handle to it.
Create a Login from the Asymmetric Key
Create a login backed by the master key and map the provider credential to it. This is the engine login TDE uses to reach the key.
USE master;
CREATE LOGIN TDE_Master_Login
FROM ASYMMETRIC KEY TDE_Master;
GO
ALTER LOGIN TDE_Master_Login
ADD CREDENTIAL DkeEkmCredential;
GOVerification
Verify your configuration with these queries.
SELECT
name,
guid,
is_enabled
FROM sys.cryptographic_providers;
GOSELECT
name,
credential_identity
FROM sys.credentials
WHERE name = 'DkeEkmCredential';
GOUSE master;
SELECT
ak.name AS KeyName,
ak.algorithm_desc,
cp.name AS ProviderName,
cp.is_enabled
FROM sys.asymmetric_keys ak
INNER JOIN sys.cryptographic_providers cp
ON ak.cryptographic_provider_guid = cp.guid
WHERE ak.name = 'TDE_Master';
GOIf the join returns a row with the provider enabled, SQL Server has successfully opened the master key through DuoKey and you are ready to enable TDE on a database.
Best Practices
Security
- Limit EKM credential access to sysadmins
- Protect config.toml with tight folder ACLs
- Enable SQL Server auditing
- Plan regular agent-key rotation
Performance
- Ensure stable network to DuoKey
- Monitor key operation latency
- Keep the host clock in sync
Maintenance
- Document all configuration
- Test disaster recovery regularly
- Preserve keystore.json while databases are encrypted