You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: public/Backup-DbaDbCertificate.ps1
+18-9Lines changed: 18 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -225,15 +225,24 @@ function Backup-DbaDbCertificate {
225
225
226
226
# because the password shouldn't go to memory...
227
227
if ($EncryptionPassword.Length-gt0-and$DecryptionPassword.Length-gt0) {
228
-
229
-
Write-Message-Level Verbose -Message "Both passwords passed in. Will export both cer and pvk."
230
-
231
-
$cert.export(
232
-
$exportPathCert,
233
-
$exportPathKey,
234
-
($EncryptionPassword|ConvertFrom-SecurePass),
235
-
($DecryptionPassword|ConvertFrom-SecurePass)
236
-
)
228
+
if ($cert.PrivateKeyEncryptionType-eq [Microsoft.SqlServer.Management.Smo.PrivateKeyEncryptionType]::MasterKey) {
229
+
Write-Message-Level Verbose -Message "Both passwords passed in but private key of $certName is encrypted by the database master key. DecryptionPassword will be ignored."
230
+
231
+
$cert.export(
232
+
$exportPathCert,
233
+
$exportPathKey,
234
+
($EncryptionPassword|ConvertFrom-SecurePass)
235
+
)
236
+
} else {
237
+
Write-Message-Level Verbose -Message "Both passwords passed in. Will export both cer and pvk."
0 commit comments