@@ -88,6 +88,13 @@ function New-DbaComputerCertificate {
8888 Useful for development environments or when no domain CA is available.
8989 Self-signed certificates will generate trust warnings unless manually added to client trust stores.
9090
91+ . PARAMETER DocumentEncryptionCert
92+ Creates a certificate suitable for use as a Column Master Key for Always Encrypted.
93+ When specified, the certificate uses KeyEncipherment key usage and includes the
94+ Document Encryption (1.3.6.1.4.1.311.10.3.11) and IKE Intermediate (1.3.6.1.5.5.8.2.2)
95+ Extended Key Usage OIDs required by Always Encrypted, instead of the default Server
96+ Authentication OID (1.3.6.1.5.5.7.3.1).
97+
9198 . PARAMETER HashAlgorithm
9299 Specifies the cryptographic hash algorithm used for certificate signing.
93100 Defaults to "Sha256" which meets current industry security standards for production environments.
@@ -180,6 +187,13 @@ function New-DbaComputerCertificate {
180187
181188 Creates a self-signed certificate using the SHA256 hashing algorithm that does not expire for 5 years
182189
190+ . EXAMPLE
191+ PS C:\> New-DbaComputerCertificate -SelfSigned -DocumentEncryptionCert
192+
193+ Creates a self-signed certificate suitable for use as a Column Master Key for Always Encrypted.
194+ The certificate includes the Document Encryption and IKE Intermediate Extended Key Usage OIDs
195+ required by SQL Server Always Encrypted.
196+
183197 #>
184198 [CmdletBinding (SupportsShouldProcess , ConfirmImpact = " Low" )]
185199 [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSUseOutputTypeCorrectly" , " " , Justification = " PSSA Rule Ignored by BOH" )]
@@ -201,6 +215,7 @@ function New-DbaComputerCertificate {
201215 [string []]$Flag = @ (" Exportable" , " PersistKeySet" ),
202216 [string []]$Dns ,
203217 [switch ]$SelfSigned ,
218+ [switch ]$DocumentEncryptionCert ,
204219 [switch ]$EnableException ,
205220 [ValidateSet (" Sha256" , " sha384" , " sha512" )]
206221 [string ]$HashAlgorithm = " Sha256" ,
@@ -400,9 +415,16 @@ function New-DbaComputerCertificate {
400415 Add-Content $certCfg " RequestType = PKCS10"
401416 }
402417 Add-Content $certCfg " HashAlgorithm = $HashAlgorithm "
403- Add-Content $certCfg " KeyUsage = 0xa0"
404- Add-Content $certCfg " [EnhancedKeyUsageExtension]"
405- Add-Content $certCfg " OID=1.3.6.1.5.5.7.3.1"
418+ if ($DocumentEncryptionCert ) {
419+ Add-Content $certCfg " KeyUsage = 0x20"
420+ Add-Content $certCfg " [EnhancedKeyUsageExtension]"
421+ Add-Content $certCfg " OID=1.3.6.1.5.5.8.2.2"
422+ Add-Content $certCfg " OID=1.3.6.1.4.1.311.10.3.11"
423+ } else {
424+ Add-Content $certCfg " KeyUsage = 0xa0"
425+ Add-Content $certCfg " [EnhancedKeyUsageExtension]"
426+ Add-Content $certCfg " OID=1.3.6.1.5.5.7.3.1"
427+ }
406428 Add-Content $certCfg " [Extensions]"
407429 Add-Content $certCfg $san
408430 Add-Content $certCfg " Critical=2.5.29.17"
0 commit comments