From 6d7a1e4a099810e3cb3d2fc4a5143bb03d676065 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 27 Oct 2015 17:38:39 -0400 Subject: [PATCH] [System/TLS]: Don't crash when we're called without user-supplied certificate validator. --- mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs | 2 ++ mcs/class/System/Mono.Net.Security/LegacySslStream.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs b/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs index 141c7526c10..e64ed968ca4 100644 --- a/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs +++ b/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs @@ -115,6 +115,8 @@ namespace Mono.Net.Security internal static ICertificateValidator GetDefaultValidator (MonoTlsSettings settings) { + if (settings == null) + return new ChainValidationHelper (null, false, null, null); if (settings.CertificateValidator == null) settings.CertificateValidator = new ChainValidationHelper (settings, false, null, null); return settings.CertificateValidator; diff --git a/mcs/class/System/Mono.Net.Security/LegacySslStream.cs b/mcs/class/System/Mono.Net.Security/LegacySslStream.cs index 8913c8a513b..876755e9f03 100644 --- a/mcs/class/System/Mono.Net.Security/LegacySslStream.cs +++ b/mcs/class/System/Mono.Net.Security/LegacySslStream.cs @@ -96,7 +96,7 @@ namespace Mono.Net.Security } public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen) - : base (innerStream, leaveInnerStreamOpen) + : this (innerStream, leaveInnerStreamOpen, null) { } @@ -104,7 +104,7 @@ namespace Mono.Net.Security : base (innerStream, leaveInnerStreamOpen) { this.settings = settings; - this.certificateValidator = settings.CertificateValidator; + this.certificateValidator = ChainValidationHelper.GetDefaultValidator (settings); } #endregion // Constructors -- 2.11.4.GIT