From 56ea528616068741383c9b166d75a0dfe78426d1 Mon Sep 17 00:00:00 2001 From: sriramvu Date: Thu, 12 Mar 2015 05:28:49 +0530 Subject: [PATCH] ignoreCertificateHandler to make OneBox setup work (to be reverted before final PR) --- .../PSRecoveryServicesClient.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClient.cs b/src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClient.cs index cba792731dec..1b501e597d46 100644 --- a/src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClient.cs +++ b/src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClient.cs @@ -32,6 +32,7 @@ using Microsoft.WindowsAzure.Management.RecoveryServices.Models; using Microsoft.WindowsAzure.Management.SiteRecovery; using Microsoft.WindowsAzure.Management.SiteRecovery.Models; +using System.Net.Security; namespace Microsoft.Azure.Commands.RecoveryServices { @@ -86,11 +87,28 @@ public RecoveryServicesManagementClient GetRecoveryServicesClient /// Azure Subscription public PSRecoveryServicesClient(AzureProfile azureProfile, AzureSubscription azureSubscription) { + if (ServicePointManager.ServerCertificateValidationCallback == null) + { + ServicePointManager.ServerCertificateValidationCallback = + IgnoreCertificateErrorHandler; + + } + this.Profile = azureProfile; this.recoveryServicesClient = AzureSession.ClientFactory.CreateClient(azureProfile, azureSubscription, AzureEnvironment.Endpoint.ServiceManagement); } + private static bool IgnoreCertificateErrorHandler + (object sender, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + SslPolicyErrors sslPolicyErrors) + { + return true; + + } + /// /// Retrieves Azure Cloud services. ///