OneIdentity / safeguard-ps

One Identity Safeguard PowerShell scripting resources
Apache License 2.0
22 stars 27 forks source link

Problem with API Module #506

Open nawazsarwar124 opened 11 months ago

nawazsarwar124 commented 11 months ago

Hello,

i have installed the safeguard-ps but encountring the error of powershell, i thought it's problem of powershell and i installed a virtualmachine but encountring the same error. Can someone please help:

PS C:\Windows\system32> Connect-Safeguard -Appliance 10.X.X.X -Insecure Provider: local Username: admin 400: Bad Request -- In C:\Program Files\WindowsPowerShell\Modules\safeguard-ps\7.4.126553\sg-utilities.psm1:181 car:5

PS C:\Windows\system32> Connect-Safeguard -Appliance 10.X.X.X -Insecure -Gui Add-Type : (0) : Impossibile trovare il file di metadati 'System.Security.Cryptography.dll' (1) : using System; In C:\Program Files\WindowsPowerShell\Modules\safeguard-ps\7.4.126553\safeguard-ps.psm1:82 car:9

petrsnd commented 10 months ago

@nawazsarwar124 I am unable to reproduce the issue you are seeing. Could you give us more information about your environment?

Can you run the following?

PS> $PSVersionTable
PS> Get-Host
nawazsarwar124 commented 10 months ago

Hello @petrsnd thanks for your reply. I resolved the problem by degrating the version as lastest version was creating problem as mentioned above.

For time being i am not using that version, maybe in future...

Thanks again for you reply.

Kevin-Andrew commented 2 months ago

I was able to reproduce the problem: image

image

And it appears that it can be fixed by just deleting the ,"System.Security.Cryptography.dll" from: https://github.com/OneIdentity/safeguard-ps/blob/release-7.5/src/safeguard-ps.psm1#L80

But then, at least for me, I immediately ran into another problem: image

So that is complaining about: https://github.com/OneIdentity/safeguard-ps/blob/release-7.5/src/safeguard-ps.psm1#L106

I don't think PowerShell supports the C# string interpolation, at least not PowerShell version 5.1. So I replaced it with:

string accessTokenUri = string.Format("https://{0}/RSTS/Login?response_type=code&code_challenge_method=S256&code_challenge={1}&redirect_uri={2}&port={3}", _appliance, OAuthCodeChallenge(CodeVerifier), redirectUri, port);

And it worked.