From a07e9582ac77254a8378e504100d68e9f80e8c31 Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 3 Sep 2020 10:24:31 +0800 Subject: [PATCH] Fix https://github.com/Azure/azure-powershell/issues/12707, which is actually securestring can not be decrypted correctly in pwsh 7 in Linux --- src/Blockchain/custom/New-AzBlockchainMember.ps1 | 4 ++-- src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1 | 2 +- src/Blockchain/custom/Update-AzBlockchainMember.ps1 | 4 ++-- src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1 | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Blockchain/custom/New-AzBlockchainMember.ps1 b/src/Blockchain/custom/New-AzBlockchainMember.ps1 index 5845275741ec..0d4b5f739e46 100644 --- a/src/Blockchain/custom/New-AzBlockchainMember.ps1 +++ b/src/Blockchain/custom/New-AzBlockchainMember.ps1 @@ -184,12 +184,12 @@ param( process { try { if ($PSBoundParameters.ContainsKey('Password')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password'] $null = $PSBoundParameters.Remove('Password') $PSBoundParameters.Add('Password', $psTxt) } if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword'] $null = $PSBoundParameters.Remove('ConsortiumManagementAccountPassword') $PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt) } diff --git a/src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1 b/src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1 index b0fef07d39d5..e8ba50cebedb 100644 --- a/src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1 +++ b/src/Blockchain/custom/New-AzBlockchainTransactionNode.ps1 @@ -135,7 +135,7 @@ param( process { try { if ($PSBoundParameters.ContainsKey('Password')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password'] $PSBoundParameters.Remove('Password') $PSBoundParameters.Add('Password', $psTxt) } diff --git a/src/Blockchain/custom/Update-AzBlockchainMember.ps1 b/src/Blockchain/custom/Update-AzBlockchainMember.ps1 index 63d29ab41e69..58a1e491ec58 100644 --- a/src/Blockchain/custom/Update-AzBlockchainMember.ps1 +++ b/src/Blockchain/custom/Update-AzBlockchainMember.ps1 @@ -141,12 +141,12 @@ param( process { try { if ($PSBoundParameters.ContainsKey('Password')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password'] $PSBoundParameters.Remove('Password') $PSBoundParameters.Add('Password', $psTxt) } if ($PSBoundParameters.ContainsKey('ConsortiumManagementAccountPassword')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['ConsortiumManagementAccountPassword'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['ConsortiumManagementAccountPassword'] $PSBoundParameters.Remove('ConsortiumManagementAccountPassword') $PSBoundParameters.Add('ConsortiumManagementAccountPassword', $psTxt) } diff --git a/src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1 b/src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1 index 50dcb18f7493..4520f593ff71 100644 --- a/src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1 +++ b/src/Blockchain/custom/Update-AzBlockchainTransactionNode.ps1 @@ -133,7 +133,7 @@ param( process { try { if ($PSBoundParameters.ContainsKey('Password')) { - $psTxt = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['Password'])) + $psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password'] $PSBoundParameters.Remove('Password') $PSBoundParameters.Add('Password', $psTxt) }