[System]: Fix possible initialization issue in MonoTlsProviderFactory. (#4987)
authorMartin Baulig <mabaul@microsoft.com>
Wed, 7 Jun 2017 15:46:21 +0000 (11:46 -0400)
committerGitHub <noreply@github.com>
Wed, 7 Jun 2017 15:46:21 +0000 (11:46 -0400)
* [Mono.Security]: Add test for MonoTlsProviderFactory.GetProvider ().

* [System]: Fix possible initialization issue in MonoTlsProviderFactory.

mcs/class/Mono.Security/Mono.Security_test.dll.sources
mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs [new file with mode: 0644]
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs

index 9d5ac35f66a98d80bdbb38d92bb63566bca9a5a1..c9e33efc77003eb666e15a8a88f87631bfb371b6 100644 (file)
@@ -27,6 +27,7 @@ Mono.Security.Cryptography/PKCS8Test.cs
 Mono.Security.Cryptography/RSAManagedTest.cs
 Mono.Security.Cryptography/SHA224ManagedTest.cs
 Mono.Security.Cryptography/SHA224Test.cs
+Mono.Security.Interface/TestProvider.cs
 Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs
 Mono.Security.Protocol.Ntlm/MessageBaseTest.cs
 Mono.Security.Protocol.Ntlm/Type1MessageTest.cs
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs b/mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs
new file mode 100644 (file)
index 0000000..a57cfe1
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// TestProvider.cs
+//
+// Author:
+//       Martin Baulig <mabaul@microsoft.com>
+//
+// Copyright (c) 2017 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+using Mono.Security;
+using Mono.Security.Interface;
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Security
+{
+       [TestFixture]
+       public class TestProvider
+       {
+               [Test]
+               [Category ("Martin")]
+               public void GetProvider ()
+               {
+                       var provider = MonoTlsProviderFactory.GetProvider ();
+                       Assert.IsNotNull (provider, "TLS Provider");
+               }
+       }
+}
index 96d81315139bdede6a05c6d2a4b36aeb5701b453..660e3b41bb6b5e5ca366a52dfbba32ad5810830e 100644 (file)
@@ -83,6 +83,8 @@ namespace Mono.Net.Security
                                if (initialized)
                                        return;
 
+                               InitializeProviderRegistration ();
+
                                MSI.MonoTlsProvider provider;
                                try {
                                        provider = CreateDefaultProviderImpl ();