add websocket auth support for .net standard 2.0 support (#281)

* add websocket auth support for .net standard 2.0 support

* format file
This commit is contained in:
Xin Yan
2019-05-14 09:43:18 -07:00
committed by Kubernetes Prow Robot
parent e42916a316
commit d6cb191be5
2 changed files with 7 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.WebSockets;
#if NET452
#if (NET452 || NETSTANDARD2_0)
using System.Net.Security;
#endif
using System.Security.Cryptography.X509Certificates;
@@ -281,7 +281,7 @@ namespace k8s
}
}
#if NET452
#if (NET452 || NETSTANDARD2_0)
if (this.CaCerts != null)
{
webSocketBuilder.SetServerCertificateValidationCallback(this.ServerCertificateValidationCallback);
@@ -368,7 +368,8 @@ namespace k8s
{
ServiceClientTracing.Exit(invocationId, null);
}
#if NET452
#if (NET452 || NETSTANDARD2_0)
if (this.CaCerts != null)
{
webSocketBuilder.CleanupServerCertificateValidationCallback(this.ServerCertificateValidationCallback);
@@ -378,7 +379,7 @@ namespace k8s
return webSocket;
}
#if NET452
#if (NET452 || NETSTANDARD2_0)
internal bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return Kubernetes.CertificateValidationCallBack(sender, this.CaCerts, certificate, chain, sslPolicyErrors);

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
#if NET452
#if (NET452 || NETSTANDARD2_0)
using System.Net.Security;
#endif
using System.Security.Cryptography.X509Certificates;
@@ -39,7 +39,7 @@ namespace k8s
return this;
}
#if NET452
#if (NET452 || NETSTANDARD2_0)
public WebSocketBuilder SetServerCertificateValidationCallback(RemoteCertificateValidationCallback validationCallback)
{
System.Net.ServicePointManager.ServerCertificateValidationCallback += validationCallback;