Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit f72cb3f

Browse files
authored
Merge pull request #1972 from srutzky/patch-4
Fix missing / misleading statements, and formatting in CREATE and ALTER CERTIFICATE
2 parents bd5f23f + 372f377 commit f72cb3f

2 files changed

Lines changed: 60 additions & 37 deletions

File tree

docs/t-sql/statements/alter-certificate-transact-sql.md

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "ALTER CERTIFICATE (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "04/18/2019"
4+
ms.date: "04/22/2019"
55
ms.prod: sql
66
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
77
ms.reviewer: ""
@@ -28,7 +28,7 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
2828
# ALTER CERTIFICATE (Transact-SQL)
2929
[!INCLUDE[tsql-appliesto-ss2008-asdb-xxxx-pdw-md](../../includes/tsql-appliesto-ss2008-asdb-xxxx-pdw-md.md)]
3030

31-
Changes the private key used to encrypt a certificate, or adds one if none is present. Changes the availability of a certificate to [!INCLUDE[ssSB](../../includes/sssb-md.md)].
31+
Changes the password used to encrypt the private key of a certificate, removes the private key, or imports the private key if none is present. Changes the availability of a certificate to [!INCLUDE[ssSB](../../includes/sssb-md.md)].
3232

3333
![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
3434

@@ -39,13 +39,20 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
3939
4040
ALTER CERTIFICATE certificate_name
4141
REMOVE PRIVATE KEY
42-
| WITH PRIVATE KEY ( <private_key_spec> [ ,... ] )
43-
| WITH ACTIVE FOR BEGIN_DIALOG = [ ON | OFF ]
42+
| WITH PRIVATE KEY ( <private_key_spec> )
43+
| WITH ACTIVE FOR BEGIN_DIALOG = { ON | OFF }
4444
4545
<private_key_spec> ::=
46-
[ FILE = 'path_to_private_key' | BINARY = private_key_bits ]
47-
| DECRYPTION BY PASSWORD = 'key_password'
48-
| ENCRYPTION BY PASSWORD = 'password'
46+
{
47+
{ FILE = 'path_to_private_key' | BINARY = private_key_bits }
48+
[ , DECRYPTION BY PASSWORD = 'current_password' ]
49+
[ , ENCRYPTION BY PASSWORD = 'new_password' ]
50+
}
51+
|
52+
{
53+
[ DECRYPTION BY PASSWORD = 'current_password' ]
54+
[ [ , ] ENCRYPTION BY PASSWORD = 'new_password' ]
55+
}
4956
```
5057

5158
```
@@ -62,24 +69,29 @@ ALTER CERTIFICATE certificate_name
6269

6370
## Arguments
6471
*certificate_name*
65-
Is the unique name by which the certificate is known in database.
72+
Is the unique name by which the certificate is known in the database.
6673

67-
FILE **='**_path\_to\_private\_key_**'**
68-
Specifies the complete path, including file name, to the private key. This parameter can be a local path or a UNC path to a network location. This file will be accessed within the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account. When you use this option, you must make sure that the service account has access to the specified file.
74+
REMOVE PRIVATE KEY
75+
Specifies that the private key should no longer be maintained inside the database.
76+
77+
WITH PRIVATE KEY
78+
Specifies that the private key of the certificate is loaded into SQL Server.
79+
80+
FILE ='*path_to_private_key*'
81+
Specifies the complete path, including file name, to the private key. This parameter can be a local path or a UNC path to a network location. This file will be accessed within the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account. When you use this option, make sure the service account has access to the specified file.
82+
83+
If only a file name is specified, the file is saved in the default user data folder for the instance. This folder might (or might not) be the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder. For SQL Server Express LocalDB, the default user data folder for the instance is the path specified by the `%USERPROFILE%` environment variable for the account that created the instance.
6984

70-
BINARY **='**_private\_key\_bits_**'**
85+
BINARY ='*private_key_bits*'
7186
**Applies to**: [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].
7287

7388
Private key bits specified as binary constant. These bits can be in encrypted form. If encrypted, the user must provide a decryption password. Password policy checks are not performed on this password. The private key bits should be in a PVK file format.
7489

75-
DECRYPTION BY PASSWORD **='**_key\_password_**'**
90+
DECRYPTION BY PASSWORD ='*current_password*'
7691
Specifies the password that is required to decrypt the private key.
7792

78-
ENCRYPTION BY PASSWORD **='**_password_**'**
79-
Specifies the password used to encrypt the private key of the certificate in the database. *password* must meet the Windows password policy requirements of the computer that is running the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. For more information, see [Password Policy](../../relational-databases/security/password-policy.md).
80-
81-
REMOVE PRIVATE KEY
82-
Specifies that the private key should no longer be maintained inside the database.
93+
ENCRYPTION BY PASSWORD ='*new_password*'
94+
Specifies the password used to encrypt the private key of the certificate in the database. *new_password* must meet the Windows password policy requirements of the computer that is running the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. For more information, see [Password Policy](../../relational-databases/security/password-policy.md).
8395

8496
ACTIVE FOR BEGIN_DIALOG **=** { ON | OFF }
8597
Makes the certificate available to the initiator of a [!INCLUDE[ssSB](../../includes/sssb-md.md)] dialog conversation.
@@ -89,14 +101,16 @@ ALTER CERTIFICATE certificate_name
89101

90102
The DECRYPTION BY PASSWORD clause can be omitted if the password in the file is protected with a null password.
91103

92-
When the private key of a certificate that already exists in the database is imported from a file, the private key will be automatically protected by the database master key. To protect the private key with a password, use the ENCRYPTION BY PASSWORD phrase.
104+
When the private key of a certificate that already exists in the database is imported, the private key will be automatically protected by the database master key. To protect the private key with a password, use the ENCRYPTION BY PASSWORD clause.
93105

94-
The REMOVE PRIVATE KEY option will delete the private key of the certificate from the database. You can remove the private key when the certificate will be used to verify signatures or in [!INCLUDE[ssSB](../../includes/sssb-md.md)] scenarios that do not require a private key. Do not remove the private key of a certificate that protects a symmetric key.
106+
The REMOVE PRIVATE KEY option will delete the private key of the certificate from the database. You can remove the private key when the certificate will be used to verify signatures or in [!INCLUDE[ssSB](../../includes/sssb-md.md)] scenarios that do not require a private key. Do not remove the private key of a certificate that protects a symmetric key. The private key will need to be restored in order to sign any additional modules or strings that should be verified with the certificate, or to decrypt a value that has been encrypted with the certificate.
95107

96108
You do not have to specify a decryption password when the private key is encrypted by using the database master key.
109+
110+
To change the password used for encrypting the private key, do not specify either the FILE or BINARY clauses.
97111

98112
> [!IMPORTANT]
99-
> Always make an archival copy of a private key before removing it from a database. For more information, see [BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md).
113+
> Always make an archival copy of a private key before removing it from a database. For more information, see [BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md) and [CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md).
100114
101115
The WITH PRIVATE KEY option is not available in a contained database.
102116

@@ -105,29 +119,28 @@ ALTER CERTIFICATE certificate_name
105119

106120
## Examples
107121

108-
### A. Changing the password of a certificate
122+
### A. Removing the private key of a certificate
109123

110124
```
111125
ALTER CERTIFICATE Shipping04
112-
WITH PRIVATE KEY (DECRYPTION BY PASSWORD = 'pGF$5DGvbd2439587y',
113-
ENCRYPTION BY PASSWORD = '4-329578thlkajdshglXCSgf');
126+
REMOVE PRIVATE KEY;
114127
GO
115128
```
116129

117130
### B. Changing the password that is used to encrypt the private key
118131

119132
```
120133
ALTER CERTIFICATE Shipping11
121-
WITH PRIVATE KEY (ENCRYPTION BY PASSWORD = '34958tosdgfkh##38',
122-
DECRYPTION BY PASSWORD = '95hkjdskghFDGGG4%');
134+
WITH PRIVATE KEY (DECRYPTION BY PASSWORD = '95hkjdskghFDGGG4%',
135+
ENCRYPTION BY PASSWORD = '34958tosdgfkh##38');
123136
GO
124137
```
125138

126139
### C. Importing a private key for a certificate that is already present in the database
127140

128141
```
129142
ALTER CERTIFICATE Shipping13
130-
WITH PRIVATE KEY (FILE = 'c:\\importedkeys\Shipping13',
143+
WITH PRIVATE KEY (FILE = 'c:\importedkeys\Shipping13',
131144
DECRYPTION BY PASSWORD = 'GDFLKl8^^GGG4000%');
132145
GO
133146
```
@@ -141,11 +154,15 @@ GO
141154
```
142155

143156
## See Also
144-
[CREATE CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/create-certificate-transact-sql.md)
145-
[DROP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/drop-certificate-transact-sql.md)
146-
[BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md)
147-
[Encryption Hierarchy](../../relational-databases/security/encryption/encryption-hierarchy.md)
157+
[CREATE CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/create-certificate-transact-sql.md)
158+
[DROP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/drop-certificate-transact-sql.md)
159+
[BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md)
160+
[Encryption Hierarchy](../../relational-databases/security/encryption/encryption-hierarchy.md)
148161
[EVENTDATA &#40;Transact-SQL&#41;](../../t-sql/functions/eventdata-transact-sql.md)
162+
[CERTENCODED &#40;Transact-SQL&#41;](../../t-sql/functions/certencoded-transact-sql.md)
163+
[CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md)
164+
[CERT_ID &#40;Transact-SQL&#41;](../../t-sql/functions/cert-id-transact-sql.md)
165+
[CERTPROPERTY &#40;Transact-SQL&#41;](../../t-sql/functions/certproperty-transact-sql.md)
149166

150167

151168

docs/t-sql/statements/create-certificate-transact-sql.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "CREATE CERTIFICATE (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "09/07/2018"
4+
ms.date: "04/22/2019"
55
ms.prod: sql
66
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
77
ms.reviewer: ""
@@ -120,18 +120,19 @@ CREATE CERTIFICATE certificate_name
120120
> [!IMPORTANT]
121121
> Azure SQL Database does not support creating a certificate from a file or using private key files.
122122
123+
BINARY =*asn_encoded_certificate*
124+
ASN encoded certificate bytes specified as a binary constant.
125+
**Applies to**: [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].
126+
123127
WITH PRIVATE KEY
124-
Specifies that the private key of the certificate is loaded into [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. This clause is only valid when the certificate is being created from a file. To load the private key of an assembly, use [ALTER CERTIFICATE](../../t-sql/statements/alter-certificate-transact-sql.md).
128+
Specifies that the private key of the certificate is loaded into [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. This clause is invalid when the certificate is being created from an assembly. To load the private key of a certificate created from an assembly, use [ALTER CERTIFICATE](../../t-sql/statements/alter-certificate-transact-sql.md).
125129

126130
FILE ='*path_to_private_key*'
127131
Specifies the complete path, including file name, to the private key. *path_to_private_key* can be a local path or a UNC path to a network location. The file is accessed in the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account. This account must have the necessary file-system permissions.
128132

129133
> [!IMPORTANT]
130134
> This option is not available in a contained database or in Azure SQL Database.
131135
132-
asn_encoded_certificate
133-
ASN encoded certificate bits specified as a binary constant.
134-
135136
BINARY =*private_key_bits*
136137
**Applies to**: [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].
137138

@@ -156,7 +157,7 @@ CREATE CERTIFICATE certificate_name
156157
Makes the certificate available to the initiator of a [!INCLUDE[ssSB](../../includes/sssb-md.md)] dialog conversation. The default value is ON.
157158

158159
## Remarks
159-
A certificate is a database-level securable that follows the X.509 standard and supports X.509 V1 fields. CREATE CERTIFICATE can load a certificate from a file or assembly. This statement can also generate a key pair and create a self-signed certificate.
160+
A certificate is a database-level securable that follows the X.509 standard and supports X.509 V1 fields. CREATE CERTIFICATE can load a certificate from a file, a binary constant, or an assembly. This statement can also generate a key pair and create a self-signed certificate.
160161

161162
The Private Key must be \<= 2500 bytes in encrypted format. Private keys generated by [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] are 1024 bits long through [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] and are 2048 bits long beginning with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)]. Private keys imported from an external source have a minimum length of 384 bits and a maximum length of 4,096 bits. The length of an imported private key must be an integer multiple of 64 bits. Certificates used for TDE are limited to a private key size of 3456 bits.
162163

@@ -227,7 +228,10 @@ GO
227228
```
228229
> [!IMPORTANT]
229230
> Azure SQL Database does not support creating a certificate from a file.
230-
231+
232+
> [!IMPORTANT]
233+
> Starting in [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)], the ['CLR strict security'](../../database-engine/configure-windows/clr-strict-security.md) server configuration option prevents loading assemblies without first setting up the security for them. Load the certificate, create a login from it, grant `UNSAFE ASSEMBLY` to that login, and then load the assembly.
234+
231235
### D. Creating a self-signed certificate
232236
The following example creates a certificate called `Shipping04` without specifying an encryption password. This example can be used with [!INCLUDE[ssPDW](../../includes/sspdw-md.md)].
233237

@@ -245,6 +249,8 @@ GO
245249
[EVENTDATA &#40;Transact-SQL&#41;](../../t-sql/functions/eventdata-transact-sql.md)
246250
[CERTENCODED &#40;Transact-SQL&#41;](../../t-sql/functions/certencoded-transact-sql.md)
247251
[CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md)
252+
[CERT_ID &#40;Transact-SQL&#41;](../../t-sql/functions/cert-id-transact-sql.md)
253+
[CERTPROPERTY &#40;Transact-SQL&#41;](../../t-sql/functions/certproperty-transact-sql.md)
248254

249255

250256

0 commit comments

Comments
 (0)