Skip to content

Commit 56ea528

Browse files
committed
ignoreCertificateHandler to make OneBox setup work (to be reverted before final PR)
1 parent ce314ad commit 56ea528

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClient.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using Microsoft.WindowsAzure.Management.RecoveryServices.Models;
3333
using Microsoft.WindowsAzure.Management.SiteRecovery;
3434
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
35+
using System.Net.Security;
3536

3637
namespace Microsoft.Azure.Commands.RecoveryServices
3738
{
@@ -86,11 +87,28 @@ public RecoveryServicesManagementClient GetRecoveryServicesClient
8687
/// <param name="azureSubscription">Azure Subscription</param>
8788
public PSRecoveryServicesClient(AzureProfile azureProfile, AzureSubscription azureSubscription)
8889
{
90+
if (ServicePointManager.ServerCertificateValidationCallback == null)
91+
{
92+
ServicePointManager.ServerCertificateValidationCallback =
93+
IgnoreCertificateErrorHandler;
94+
95+
}
96+
8997
this.Profile = azureProfile;
9098
this.recoveryServicesClient =
9199
AzureSession.ClientFactory.CreateClient<RecoveryServicesManagementClient>(azureProfile, azureSubscription, AzureEnvironment.Endpoint.ServiceManagement);
92100
}
93101

102+
private static bool IgnoreCertificateErrorHandler
103+
(object sender,
104+
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
105+
System.Security.Cryptography.X509Certificates.X509Chain chain,
106+
SslPolicyErrors sslPolicyErrors)
107+
{
108+
return true;
109+
110+
}
111+
94112
/// <summary>
95113
/// Retrieves Azure Cloud services.
96114
/// </summary>

0 commit comments

Comments
 (0)