Skip to main content

Quick Start Guide

Get DuoKey SQL EKM running and encrypt your first database

Applies to:
SQL Server 2016+30-45 min setupAdministrator access required

Overview

This quick start guide walks you through encrypting your first SQL Server database with DuoKey EKM. By the end, you'll have:

DuoKey App

SQL EKM app configured in DuoKey platform

EKM Provider

Cryptographic provider installed on SQL Server

Credentials

SQL Server configured with DuoKey authentication

Encrypted DB

Test database encrypted with TDE

Prerequisites

Prerequisites

  • SQL Server 2016+ (Enterprise, Standard, or Developer Edition)
  • Windows Server 2012 R2+ or Windows 10/11
  • Administrator access to SQL Server machine
  • DuoKey platform account with app creation permissions
  • Network access to DuoKey (HTTPS port 443)
  • SQL Server Management Studio (SSMS) installed
Caution
SQL Server Express edition does not support Extensible Key Management. Verify your SQL Server edition before proceeding.

Phase 1: DuoKey Platform Setup

1

DuoKey Platform Setup

~5 minutes
1

Log in to DuoKey Platform

Navigate to the DuoKey cloud platform and sign in with your credentials.

2

Create SQL EKM App

Go to Apps → Create New APP → Select DuoKey for SQL → Click Install Now

3

Configure the App

  • Enter an App Name (e.g., "Production-SQL-EKM")
  • Add a description (optional)
  • Assign roles for access control
  • Select or create a vault for your keys
4

Save Credentials

Download the setup file and securely note:

  • Client ID - Unique identifier for the app
  • Client Secret - Secret key for authentication
  • Password - Additional app password
Important
Store your credentials securely! The Client Secret and Password cannot be retrieved later from the DuoKey platform. You'll need them for SQL Server configuration.

Detailed Guide: Create SQL EKM App

Phase 2: SQL Server Installation

2

Install EKM Provider

~10 minutes
1

Extract Setup Files

Extract the downloaded setup ZIP file to a temporary location.

2

Run Installer

Right-click setup.exe → Run as Administrator

Note
Windows may show a protection dialog. Click "More Info" then "Run anyway".
3

Complete Installation Wizard

  • Accept the license agreement
  • Choose installation folder (default recommended)
  • Select log level (Info recommended for initial setup)
  • Click Install and wait for completion
4

Verify Installation

Confirm these DLL files exist in C:\Windows\System32:

  • DuoKeyCryptoProvider.dll
  • libcurl.dll
  • zlib1.dll
  • fmt.dll
Verification QuerySQL
-- Verify DLL is accessible by SQL Server
EXEC xp_fileexist 'C:\Windows\System32\DuoKeyCryptoProvider.dll';
GO

Detailed Guide: Install EKM Provider

Phase 3: SQL Server Configuration

3

Configure SQL Server

~10 minutes

Open SQL Server Management Studio (SSMS), connect to your instance, and execute the following configuration script. Replace all placeholders with your actual values.

Complete Configuration Script

T-SQLReplace placeholders
-- =============================================
-- DuoKey SQL EKM Configuration Script
-- Replace <placeholders> with your values
-- =============================================

-- Step 1: Enable EKM
sp_configure 'show advanced', 1;
GO
RECONFIGURE;
GO
sp_configure 'EKM provider enabled', 1;
GO
RECONFIGURE;
GO

-- Step 2: Create Cryptographic Provider
CREATE CRYPTOGRAPHIC PROVIDER DuoKeyProvider
FROM FILE = 'C:\Windows\System32\DuoKeyCryptoProvider.dll';
GO

-- Step 3: Create Credentials
-- Format: client_secret<!COCKPITPW!>password<!COCKPITPW!>CockpitIntrospectPwd
CREATE CREDENTIAL DuoKeyCredential
WITH IDENTITY = '<your_client_id>',
SECRET = '<your_client_secret><!COCKPITPW!><your_password><!COCKPITPW!>CockpitIntrospectPwd'
FOR CRYPTOGRAPHIC PROVIDER DuoKeyProvider;
GO

-- Step 4: Map Credential to Login
ALTER LOGIN [sa]
ADD CREDENTIAL DuoKeyCredential;
GO

-- Step 5: Create Asymmetric Key
USE master;
GO
CREATE ASYMMETRIC KEY SQL_EKM_Key
FROM PROVIDER DuoKeyProvider
WITH ALGORITHM = RSA_2048,
PROVIDER_KEY_NAME = 'SQL_EKM_Key',
CREATION_DISPOSITION = CREATE_NEW;
GO

-- Step 6: Create Key Credentials
CREATE CREDENTIAL SQL_EKM_Key_Cred
WITH IDENTITY = '<your_client_id>',
SECRET = '<your_client_secret><!COCKPITPW!><your_password><!COCKPITPW!>CockpitIntrospectPwd'
FOR CRYPTOGRAPHIC PROVIDER DuoKeyProvider;
GO

-- Step 7: Create Key Login
CREATE LOGIN SQL_EKM_Key_Login
FROM ASYMMETRIC KEY SQL_EKM_Key;
GO

ALTER LOGIN SQL_EKM_Key_Login
ADD CREDENTIAL SQL_EKM_Key_Cred;
GO

PRINT 'Configuration complete. Enable Encrypt operation in DuoKey Cockpit.';
GO
Enable Encrypt Operation

Before proceeding to Phase 4, you must enable the Encrypt operation in DuoKey:

  1. Log in to DuoKey Cockpit
  2. Navigate to Keys → Search for SQL_EKM_Key
  3. In Cryptographic Operations, enable Encrypt
  4. Save changes

Detailed Guide: Configure SQL Server

Phase 4: Database Encryption

4

Encrypt Your First Database

~5 minutes

Now let's create a test database and encrypt it using TDE with DuoKey EKM.

Database Encryption ScriptSQL
-- Create test database
CREATE DATABASE TestEncryptedDB;
GO

-- Create Database Encryption Key
USE TestEncryptedDB;
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER ASYMMETRIC KEY SQL_EKM_Key;
GO

-- Enable encryption
ALTER DATABASE TestEncryptedDB
SET ENCRYPTION ON;
GO

-- Verify encryption status
SELECT
    DB_NAME(database_id) AS [Database],
    CASE encryption_state
        WHEN 0 THEN 'No encryption key'
        WHEN 1 THEN 'Unencrypted'
        WHEN 2 THEN 'Encryption in progress'
        WHEN 3 THEN 'Encrypted'
        WHEN 4 THEN 'Key change in progress'
        WHEN 5 THEN 'Decryption in progress'
    END AS [Status],
    percent_complete AS [Progress %]
FROM sys.dm_database_encryption_keys
WHERE DB_NAME(database_id) = 'TestEncryptedDB';
GO
Tip
Encryption state 3 means the database is fully encrypted. State 2 means encryption is still in progress - wait for it to complete before proceeding.

Detailed Guide: Database Encryption

Verification

Run these queries to verify your complete setup is working correctly:

Verification QueriesSQL
-- 1. EKM Provider Status
SELECT name, guid, version
FROM sys.cryptographic_providers;
GO

-- 2. Credentials Created
SELECT name, credential_identity, create_date
FROM sys.credentials
WHERE name LIKE '%DuoKey%' OR name LIKE '%EKM%';
GO

-- 3. Asymmetric Keys
SELECT name, algorithm_desc, key_length, thumbprint
FROM sys.asymmetric_keys;
GO

-- 4. Encrypted Databases
SELECT
    d.name AS DatabaseName,
    d.is_encrypted,
    dek.encryption_state
FROM sys.databases d
LEFT JOIN sys.dm_database_encryption_keys dek
    ON d.database_id = dek.database_id
WHERE d.is_encrypted = 1;
GO

Verification Checklist

EKM ProviderDuoKeyProvider visible in sys.cryptographic_providers
CredentialsDuoKeyCredential and SQL_EKM_Key_Cred created
Asymmetric KeySQL_EKM_Key with RSA_2048 algorithm
Database EncryptedTestEncryptedDB with encryption_state = 3

Troubleshooting Quick Reference

Common Issues & Solutions

IssueCauseSolution
EKM not enabledSQL Server edition or configVerify edition; run sp_configure commands
Cannot create providerDLL not foundVerify DuoKeyCryptoProvider.dll in System32
Credential format errorInvalid SECRET formatCheck <!COCKPITPW!> delimiters
Key creation failsEncrypt not enabledEnable Encrypt operation in DuoKey Cockpit
Connection timeoutNetwork issueVerify HTTPS 443 access to DuoKey platform

Full Troubleshooting Guide

Next Steps

Congratulations! You've successfully set up DuoKey SQL EKM and encrypted your first database. Here's what to explore next: