OneIdentity / safeguard-ps

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

v7.1 fails export-safeguardbackup against Safeguard appliance 7.0 and 7.2 (likely 7.1 as well) #461

Closed taniaengel closed 1 year ago

taniaengel commented 1 year ago

Tried to download a backup with safeguard-ps running powershell 5.1.19041.2364 . 7.0.0.18433 and 7.2 appliances failed the same way:

PS C:\Users\Tania> export-safeguardbackup 44d7b899-c9d3-4f15-ac92-01bc30ad33fb
export-safeguardbackup : c:\Users\Tania\AppData\Local\Temp\2405mje2\2405mje2.0.cs(75) : '**System.Net.Http.HttpContent'
does not contain a definition for 'ReadAsStream' and no extension method 'ReadAsStream**' accepting a first argument of
type 'System.Net.Http.HttpContent' could be found (are you missing a using directive or an assembly reference?)
c:\Users\Tania\AppData\Local\Temp\2405mje2\2405mje2.0.cs(74) :                         using (var fileStream = new
FileStream(PathAndFilename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
c:\Users\Tania\AppData\Local\Temp\2405mje2\2405mje2.0.cs(75) : >>>                         using (var contentStream =
response.Content.ReadAsStream())
c:\Users\Tania\AppData\Local\Temp\2405mje2\2405mje2.0.cs(76) :                         {
At line:1 char:1
+ export-safeguardbackup 44d7b899-c9d3-4f15-ac92-01bc30ad33fb
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Export-SafeguardBackup

========================================================================

Upgraded to Powershell 7.3.2 and I got a X509Certificate2 error:

PowerShell 7.3.2

PS C:\Users\Tania> $PSversionTable

Name                           Value
----                           -----
**PSVersion                      7.3.2**
**PSEdition                      Core**
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
PS C:\Users\Tania> Connect-Safeguard -Insecure 10.5.33.14 local Uber
Password: ********
Login Successful.
PS C:\Users\Tania> export-safeguardbackup 44d7b899-c9d3-4f15-ac92-01bc30ad33fb
Export-SafeguardBackup: (35,94): **error CS1069: The type name 'X509Certificate2' could not be found in the namespace 'System.Security.Cryptography.X509Certificates'**. This type has been forwarded to assembly 'System.Security.Cryptography, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
    private static bool ServerCertificateCustomValidation(HttpRequestMessage requestMessage, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslErrors)

================================================================== Upload big backup with Powershell 7.3 I get the same certificate error:


PS C:\Users\Tania> Connect-Safeguard -Insecure 10.5.33.142 local Admin
Password: ********
Login Successful.
PS C:\Users\Tania> Import-SafeguardBackup \\slcflsl03.prod.quest.corp\common\SafeguardRegressionBackups\PROD\HW\SGv7.0.0.18433ProdHw143gb.sgb
Loading backup from \\slcflsl03.prod.quest.corp\common\SafeguardRegressionBackups\PROD\HW\SGv7.0.0.18433ProdHw143gb.sgb
POSTing backup to Safeguard. This operation may take several minutes...
Import-SafeguardBackup: (114,94): **error CS1069: The type name 'X509Certificate2' could not be found in the namespace 'System.Security.Cryptography.X509Certificates'**. This type has been forwarded to assembly 'System.Security.Cryptography, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
    private static bool ServerCertificateCustomValidation(HttpRequestMessage requestMessage, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslErrors)

==================================================

Upload big backup with Powershell 5.1: different error than download backup.

PS C:\WINDOWS\system32> Connect-Safeguard -Insecure 10.5.33.142 local Admin
Password: ********
Login Successful.
PS C:\WINDOWS\system32> Import-SafeguardBackup \\slcflsl03.prod.quest.corp\common\SafeguardRegressionBackups\PROD\HW\SGv7.0.0.18433ProdHw143gb.sgb
Loading backup from \\slcflsl03.prod.quest.corp\common\SafeguardRegressionBackups\PROD\HW\SGv7.0.0.18433ProdHw143gb.sgb
POSTing backup to Safeguard. This operation may take several minutes...
Import-SafeguardBackup **: Exception calling "ReadAllBytes" with "1" argument(s): "The file is too long. This operation
is currently limited to supporting files less than 2 gigabytes in size."**
At line:1 char:1
+ Import-SafeguardBackup \\slcflsl03.prod.quest.corp\common\SafeguardRe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Import-SafeguardBackup
miroberts commented 1 year ago

@taniaengel Here is the build with this fix in it https://www.powershellgallery.com/packages/safeguard-ps/7.2.93507-pre