Skip to content

Commit 6ba852e

Browse files
authored
Fix #12707, which is actually securestring can not be decrypted correctly in pwsh 7 in Linux (#12842)
1 parent 66aa962 commit 6ba852e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Blockchain/custom/New-AzBlockchainMember.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ param(
184184
process {
185185
try {
186186
if ($PSBoundParameters.ContainsKey('Password')) {
187-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
187+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
188188
$null = $PSBoundParameters.Remove('Password')
189189
$PSBoundParameters.Add('Password', $psTxt)
190190
}
191191
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
192-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
192+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
193193
$null = $PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
194194
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
195195
}

src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ param(
135135
process {
136136
try {
137137
if ($PSBoundParameters.ContainsKey('Password')) {
138-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
138+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
139139
$PSBoundParameters.Remove('Password')
140140
$PSBoundParameters.Add('Password', $psTxt)
141141
}

src/Blockchain/custom/Update-AzBlockchainMember.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ param(
141141
process {
142142
try {
143143
if ($PSBoundParameters.ContainsKey('Password')) {
144-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
144+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
145145
$PSBoundParameters.Remove('Password')
146146
$PSBoundParameters.Add('Password', $psTxt)
147147
}
148148
if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) {
149-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword']))
149+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword']
150150
$PSBoundParameters.Remove('ConsortiumManagementAccountPassword')
151151
$PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt)
152152
}

src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ param(
133133
process {
134134
try {
135135
if ($PSBoundParameters.ContainsKey('Password')) {
136-
$psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password']))
136+
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
137137
$PSBoundParameters.Remove('Password')
138138
$PSBoundParameters.Add('Password', $psTxt)
139139
}

0 commit comments

Comments
 (0)