@@ -232,6 +232,7 @@ function ConvertTo-SgwConfigFile {
232232 $SgwConfigDirectory = ([System.IO.DirectoryInfo]$SgwConfigFile).Parent.FullName
233233
234234 # make sure that parent folder is only accessible by current user
235+ Write-Host "Profile information will be stored in $SgwConfigDirectory . Ensuring that access is only possible for current user."
235236 try {
236237 if ([environment]::OSVersion.Platform -match "win") {
237238 $Acl = Get-Acl -Path $SgwConfigDirectory
@@ -243,7 +244,7 @@ function ConvertTo-SgwConfigFile {
243244 [System.Security.AccessControl.PropagationFlags]::None,
244245 [System.Security.AccessControl.AccessControlType]::Allow)
245246 $Acl.AddAccessRule($AcessRule)
246- Set-Acl -Path $SgwConfigDirectory -AclRule -ErrorAction Stop
247+ $null = Set-Acl -Path $SgwConfigDirectory -AclRule -ErrorAction Stop
247248 }
248249 else {
249250 Invoke-Expression "chmod 700 $SgwConfigDirectory"
@@ -258,11 +259,20 @@ function ConvertTo-SgwConfigFile {
258259
259260 if ($SgwConfigFile -match "credentials$") {
260261 foreach ($Config in $Configs) {
262+ if ([environment]::OSVersion.Platform -match "win") {
263+ $secure_password = ConvertTo-SecureString -String $Config.password -AsPlainText -Force | ConvertFrom-SecureString
261264 $Output += "[$( $Config.ProfileName )]`n"
262265 $Output += "username = $($Config.username)`n"
266+ $Output += "secure_password = $($secure_password)`n"
267+ }
268+ else {
269+ # ConvertTo-SecureString is only implemented on Windows, so we need to rely on the security of the .sgw folder
270+ $Output += "[$( $Config.ProfileName )]`n"
271+ $Output += "username = $($Config.username)`n"
263272 $Output += "password = $($Config.password)`n"
264273 }
265274 }
275+ }
266276 else {
267277 foreach ($Config in $Configs) {
268278 if ($Config.ProfileName -eq "default") {
@@ -2689,6 +2699,9 @@ function Global:Get-SgwProfiles {
26892699 if ($Credential.username -and $Credential.password) {
26902700 $Config | Add-Member -MemberType NoteProperty -Name Credential -Value ([PSCredential]::new($Credential.username,($Credential.password | ConvertTo-SecureString -AsPlainText -Force))) -Force
26912701 }
2702+ elseif ($Credential.username -and $Credential.secure_password) {
2703+ $Config | Add-Member -MemberType NoteProperty -Name Credential -Value ([PSCredential]::new($Credential.username,($Credential.secure_password | ConvertTo-SecureString))) -Force
2704+ }
26922705 }
26932706
26942707 foreach ($Config in $Configs) {
0 commit comments