Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/SecurityProtocol'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddemeyer committed Apr 3, 2017
2 parents 9b77d7f + 77ebcdb commit 45f3e16
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2014 All Rights Reserved by the SDL Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Trisoft.ISHRemote.Interfaces;
using Trisoft.ISHRemote.Cmdlets;
using System.Net;

namespace Trisoft.ISHRemote.HelperClasses
{
/// <summary>
/// Provides configuration helper functions for low level network options.
/// </summary>
public static class ServicePointManagerHelper
{
private static readonly ILogger _logger = TrisoftCmdletLogger.Instance();

/// <summary>
/// Removes our custom AppDomain ssl/certificate overwrite callback using ServicePointManager by restoring our ealier backup of any existing callback
/// </summary>
public static void RestoreCertificateValidation()
{
_logger.WriteDebug("Enabling Tls, Tls11 and Tls12 security protocols");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
}
}
}
1 change: 1 addition & 0 deletions Source/ISHRemote/Trisoft.ISHRemote/ISHRemote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<Compile Include="Cmdlets\User\RemoveIshUser.cs" />
<Compile Include="Cmdlets\User\SetIshUser.cs" />
<Compile Include="Cmdlets\User\UserCmdlet.cs" />
<Compile Include="HelperClasses\ServicePointManagerHelper.cs" />
<Compile Include="Objects\FieldElements.cs" />
<Compile Include="HelperClasses\CertificateValidationHelper.cs" />
<Compile Include="HelperClasses\EnumConverter.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public IshSession(ILogger logger, string webServicesBaseUrl, string ishUserName,
{
CertificateValidationHelper.OverrideCertificateValidation();
}

ServicePointManagerHelper.RestoreCertificateValidation();
// webServicesBaseUrl should have trailing slash, otherwise .NET throws unhandy "Reference to undeclared entity 'raquo'." error
_webServicesBaseUri = (webServicesBaseUrl.EndsWith("/")) ? new Uri(webServicesBaseUrl) : new Uri(webServicesBaseUrl+"/");
_ishUserName = ishUserName == null ? Environment.UserName : ishUserName;
Expand Down

0 comments on commit 45f3e16

Please sign in to comment.