Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
Область применения: SQL Server 2019 (15.x) и более поздних версий — только для Windows
База данных SQL Azure
This article describes how to provision enclave-enabled keys that support computations inside server-side secure enclaves used for Always Encrypted with secure enclaves.
При настройке ключей с поддержкой анклава применяются общие рекомендации и процессы для управления ключами Always Encrypted. This article address details specific to Always Encrypted with secure enclaves.
To provision an enclave-enabled column master key using SQL Server Management Studio or PowerShell, make sure the new key supports enclave computations. В результате этого средство (SSMS или PowerShell) сгенерирует выражение CREATE COLUMN MASTER KEY
, которое установит ENCLAVE_COMPUTATIONS
в метаданных столбцов главного ключа в базе данных. Дополнительные сведения см. в статье CREATE COLUMN MASTER KEY (Transact-SQL).
The tool will also digitally sign the column master properties with the column master key, and it will store the signature in the database metadata. Эта подпись предотвращает вредоносное изменение параметра ENCLAVE_COMPUTATIONS
. Драйверы клиента SQL проверяют подписи, прежде чем разрешить использование анклава. Это позволяет администраторам безопасности контролировать, какие данные столбцов могут быть вычислены внутри анклава.
Свойство ENCLAVE_COMPUTATIONS
является неизменяемым — вы не сможете изменить его после определения главного ключа столбца в метаданных. To enable enclave computations using a column encryption key, that a given column master key encrypts, you need to rotate the column master key and replace it with an enclave-enabled column master key. See Rotate enclave-enabled keys.
Примечание.
Currently, both SSMS and PowerShell support enclave-enabled column master keys stored in Azure Key Vault or Windows Certificate Store. Hardware security modules (using CNG or CAPI) aren't supported.
To create an enclave-enabled column encryption key, you need to ensure that you select an enclave-enabled column master key to encrypt the new key.
В следующих разделах содержатся более подробные сведения о создании ключей, поддерживающих анклав, с помощью SSMS и PowerShell.
Provision enclave-enabled keys using SQL Server Management Studio
In SQL Server Management Studio you can provision:
- An enclave-enabled column master key using the New Column Master Key dialog.
- An enclave-enabled column encryption key using the New Column Encryption Key dialog.
The Always Encrypted Wizard also allows you to create an enclave-enabled column master key and an enclave-enabled column encryption key.
Убедитесь, что установлена последняя общедоступная версия SQL Server Management Studio (SSMS).
Provision enclave-enabled column master keys with the New Column Master Key dialog
Чтобы создать столбцовый мастер-ключ с поддержкой анклава, выполните шаги, описанные в Создание столбцовых мастер-ключей с помощью диалогового окна "Новый столбцовый ключ". Make sure you select Allow enclave computations. См. снимок экрана ниже.
Примечание.
Флажок Разрешить вычисления анклава отображается только в случае, если для базы данных настроен безопасный анклав. If you're using SQL Server, see Configure the secure enclave in SQL Server. If you're using Azure SQL Database, see Enable Always Encrypted with secure enclaves for your Azure SQL Database.
Tip
Чтобы проверить, поддерживает ли главный ключ столбца анклав, щелкните его правой кнопкой мыши в обозревателе объектов и выберите пункт Свойства. Если ключ поддерживает анклав, вычисления в анклаве: разрешено отображается в окне со свойствами ключа. Кроме того, можно использовать представление sys.column_master_keys (Transact-SQL).
Provision enclave-enabled column encryption keys with the New Column Encryption Key dialog
Чтобы подготовить ключ шифрования столбца с поддержкой анклава, выполните действия, описанные в разделе Подготовка ключей шифрования столбцов с помощью диалогового окна "Новый ключ шифрования столбца". When selecting a column master key, make sure it's enclave-enabled.
Tip
Чтобы проверить, поддерживает ли ключ шифрования столбца анклав, щелкните его правой кнопкой мыши в обозревателе объектов и выберите пункт Свойства. Если ключ поддерживает анклав, вычисления в анклаве: разрешено отображается в окне со свойствами ключа.
Настройка ключей, которые поддерживают анклав, с помощью PowerShell
Чтобы подготовить ключи с поддержкой анклава с помощью PowerShell, вам потребуется модуль SqlServer PowerShell версии 22 или более поздней.
Как правило, рабочие процессы подготовки ключей PowerShell (с разделением ролей и без него) для Always Encrypted, описанные в статье Подготовка ключей Always Encrypted с помощью PowerShell, также применимы и к ключам с поддержкой анклавов. В этом разделе приводятся конкретные сведения, касающиеся ключей, поддерживающих анклав.
Модуль SqlServer PowerShell расширяет командлеты New-SqlCertificateStoreColumnMasterKeySettings и New-SqlAzureKeyVaultColumnMasterKeySettings через параметр -AllowEnclaveComputations
, позволяя указывать столбцовый мастер-ключ с поддержкой анклава во время процесса конфигурации. Either cmdlet creates a local object containing properties of a column master key (stored in Azure Key Vault or in the Windows Certificate Store). Если указано, свойство -AllowEnclaveComputations
помечает ключ как поддерживающий работу анклавов в локальном объекте. It also causes the cmdlet to access the referenced column master key (in Azure Key Vault or in Windows Certificate Store) to digitally sign the properties of the key. Once you create a settings object for a new enclave-enabled column master key, you can use it in a subsequent invocation of the New-SqlColumnMasterKey cmdlet to create a metadata object describing the new key in the database.
Provisioning enclave-enabled column encryption keys is no different from provisioning column encryption keys that aren't enclave-enabled. You just need to make sure that a column master key used to encrypt the new column encryption key is enclave-enabled.
Примечание.
The SqlServer PowerShell module doesn't currently support provisioning enclave-enabled keys stored in hardware security modules (using CNG or CAPI).
Пример: настройка ключей с поддержкой анклава с помощью хранилища сертификатов Windows
The below end-to-end example shows how to provision enclave-enabled keys, storing the column master key stored in Windows Certificate Store. В основе сценария лежит пример из раздела Хранилище сертификатов Windows без разделения ролей (пример). Обратите внимание на использование параметра -AllowEnclaveComputations
в командлете New-SqlCertificateStoreColumnMasterKeySettings — это единственное различие между рабочими процессами в двух примерах.
# Create a column master key in Windows Certificate Store.
$cert = New-SelfSignedCertificate -Subject "AlwaysEncryptedCert" -CertStoreLocation Cert:CurrentUser\My -KeyExportPolicy Exportable -Type DocumentEncryptionCert -KeyUsage DataEncipherment -KeySpec KeyExchange
# Import the SqlServer module.
Import-Module "SqlServer" -MinimumVersion 22.0.50
# Connect to your database.
$serverName = "<server name>"
$databaseName = "<database name>"
# Change the authentication method in the connection string, if needed.
$connStr = "Server = " + $serverName + "; Database = " + $databaseName + "; Integrated Security = True; TrustServerCertificate = True"
$database = Get-SqlDatabase -ConnectionString $connStr
# Create a SqlColumnMasterKeySettings object for your column master key
# using the -AllowEnclaveComputations parameter.
$cmkSettings = New-SqlCertificateStoreColumnMasterKeySettings -CertificateStoreLocation "CurrentUser" -Thumbprint $cert.Thumbprint -AllowEnclaveComputations
# Create column master key metadata in the database.
$cmkName = "CMK1"
New-SqlColumnMasterKey -Name $cmkName -InputObject $database -ColumnMasterKeySettings $cmkSettings
# Generate a column encryption key, encrypt it with the column master key and create column encryption key metadata in the database.
$cekName = "CEK1"
New-SqlColumnEncryptionKey -Name $cekName -InputObject $database -ColumnMasterKey $cmkName
Пример: создание ключей с поддержкой анклавов с помощью Azure Key Vault
The below end-to-end example shows how to provision enclave-enabled keys, storing the column master key in a key vault in Azure Key Vault. В основе сценария лежит пример из раздела Azure Key Vault без разделения ролей (пример). Важно отметить два различия между рабочими процессами для ключей с поддержкой анклавов и ключей без такой поддержки.
- In the below script, the New-SqlCertificateStoreColumnMasterKeySettings uses the
-AllowEnclaveComputations
parameter to make the new column master key enclave-enabled. - The below script uses the Get-AzAccessToken cmdlet to obtain an access token for key vaults. Это необходимо, потому что New-SqlAzureKeyVaultColumnMasterKeySettings должен иметь доступ к Azure Key Vault для подписывания свойств главного ключа столбца.
# Create a column master key in Azure Key Vault.
Import-Module "SqlServer" -MinimumVersion 22.0.50
Import-Module Az.Accounts -MinimumVersion 2.2.0
Connect-AzAccount
$SubscriptionId = "<Azure SubscriptionId>"
$resourceGroup = "<resource group name>"
$azureLocation = "<datacenter location>"
$akvName = "<key vault name>"
$akvKeyName = "<key name>"
$azureCtx = Set-AzConteXt -SubscriptionId $SubscriptionId # Sets the context for the below cmdlets to the specified subscription.
New-AzResourceGroup -Name $resourceGroup -Location $azureLocation # Creates a new resource group - skip, if your desired group already exists.
New-AzKeyVault -VaultName $akvName -ResourceGroupName $resourceGroup -Location $azureLocation # Creates a new key vault - skip if your vault already exists.
Set-AzKeyVaultAccessPolicy -VaultName $akvName -ResourceGroupName $resourceGroup -PermissionsToKeys get, create, delete, list, wrapKey,unwrapKey, sign, verify -UserPrincipalName $azureCtx.Account
$akvKey = Add-AzKeyVaultKey -VaultName $akvName -Name $akvKeyName -Destination "Software"
# Connect to your database.
$serverName = "<server name>"
$databaseName = "<database name>"
# Change the authentication method in the connection string, if needed.
$connStr = "Server = " + $serverName + "; Database = " + $databaseName + "; Integrated Security = True; TrustServerCertificate = True"
$database = Get-SqlDatabase -ConnectionString $connStr
# Obtain an access token for key vaults.
$keyVaultAccessToken = (Get-AzAccessToken -ResourceUrl https://vault.azure.net).Token
# Create a SqlColumnMasterKeySettings object for your column master key.
$cmkSettings = New-SqlAzureKeyVaultColumnMasterKeySettings -KeyURL $akvKey.ID -AllowEnclaveComputations -KeyVaultAccessToken $keyVaultAccessToken
# Create column master key metadata in the database.
$cmkName = "CMK1"
New-SqlColumnMasterKey -Name $cmkName -InputObject $database -ColumnMasterKeySettings $cmkSettings
# Generate a column encryption key, encrypt it with the column master key and create column encryption key metadata in the database.
$cekName = "CEK1"
New-SqlColumnEncryptionKey -Name $cekName -InputObject $database -ColumnMasterKey $cmkName -KeyVaultAccessToken $keyVaultAccessToken
Связанный контент
- Выполнение инструкций Transact-SQL с помощью безопасных анклавов
- Configure column encryption in-place using Always Encrypted with secure enclaves
- Enable Always Encrypted with secure enclaves for existing encrypted columns
- Разрабатывайте приложения с использованием технологии Always Encrypted и защищенных анклавов
- Getting started using Always Encrypted with secure enclaves
- Manage keys for Always Encrypted with secure enclaves
- CREATE COLUMN MASTER KEY (Transact-SQL)