dnewsholme / PasswordState-Management

Powershell Module For Management of Passwordstate. (Powershell Core Compatible)
GNU General Public License v3.0
39 stars 14 forks source link

ToPSCredential() Password in wrong format in 4.4.29 #130

Closed eizedev closed 3 years ago

eizedev commented 3 years ago

Hi @dnewsholme

We recognized, after updating to 4.4.29, that your change in commit 0137baf8a714f351fec42e7e80ec15c4d55224ad of the PasswordResult class broke the ToPSCredential() method for already encrypted passwords.

After calling the method ToPSCredential() the already encrypted password (not using setplaintextpassword Config) gets encrypted again, so if you call this, the last step (method GetNetworkCredential() from PSCredential) should get the clear text password, but the password is an EncryptedPassword, so the PSCredential Object is not usable.

$abc = Get-PasswordStatePassword -PasswordID 215
$abc.ToPSCredential()
$abc.ToPSCredential().GetNetworkCredential().Password

In 4.4.28 it is working, so it must be related to your change from yesterday. ($this.Password -> $this.Password.Password)

I was about to have a look at it myself, but I don't have much time for that right now, maybe you could have a look at it?

(Edit: you could also use -isnot [string] instead of .GetType().Name -ne 'String')

Thanks, René

dnewsholme commented 3 years ago

Sorry I'll take a look now.

eizedev commented 3 years ago

Tried 4.4.30, looking good! 👍🏻