Skip to content

Commit e3ec9fd

Browse files
authored
Merge pull request #68 from dbroeglin/fix/securestring-to-bstr
Fixing Add-NSCertKeyPair on PS v 6.0
2 parents 1c36802 + dbe1d79 commit e3ec9fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

NetScaler/Public/Add-NSCertKeyPair.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ function Add-NSCertKeyPair {
104104
$params.Add('key', $KeyPath)
105105
}
106106
if (($CertKeyFormat -in 'PEM','PFX') -and $Password) {
107-
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)
108-
$unsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
107+
$creds = [System.Management.Automation.PSCredential]::new("dummy", $Password)
108+
$unsecurePassword = $creds.GetNetworkCredential().Password
109109
$params.Add("passplain",$unsecurePassword)
110110
}
111111
$response = _InvokeNSRestApi -Session $Session -Method POST -Type sslcertkey -Payload $params -Action add
@@ -114,4 +114,4 @@ function Add-NSCertKeyPair {
114114
}
115115
}
116116
}
117-
}
117+
}

0 commit comments

Comments
 (0)