Fix some compiler warnings in Mono.Security and System.
authorMartin Baulig <martin.baulig@xamarin.com>
Sat, 12 Dec 2015 18:15:10 +0000 (13:15 -0500)
committerJoao Matos <joao@tritao.eu>
Tue, 5 Jan 2016 16:19:35 +0000 (16:19 +0000)
mcs/class/Mono.Security/Makefile
mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs
mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs
mcs/class/System/Mono.Net.Security/LegacySslStream.cs
mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs

index f9508b9c8a66994e9269ece8b6d0ce94b71a7418..d15fb96bc242707ece65c70cac0c5d179f194a93 100644 (file)
@@ -5,7 +5,7 @@ include ../../build/rules.make
 LIBRARY = Mono.Security.dll
 LOCAL_MCS_FLAGS = -lib:$(the_libdir_base)bare
 LIB_REFS = System
-LIB_MCS_FLAGS = -unsafe -nowarn:1030
+LIB_MCS_FLAGS = -unsafe -nowarn:1030,3009
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:169,219,618,672
 
 include ../../build/library.make
index a02a3f9316a75fc5c827426c846c66982232b29b..d7eb2291f6d25f449d84a0def8b0f9a966984c3a 100644 (file)
@@ -52,12 +52,11 @@ namespace Mono.Security.Interface
                        this.policy_errors = policy_errors;
                }
 
-               internal ValidationResult (bool trusted, bool user_defined, int error_code)
+               internal ValidationResult (bool trusted, bool user_denied, int error_code)
                {
                        this.trusted = trusted;
                        this.user_denied = user_denied;
                        this.error_code = error_code;
-                       this.policy_errors = policy_errors;
                }
 
                public bool Trusted {
index afa21ff1debc4216ecd6357afe1c71e72e9706cf..7e42720d17c7fee392c9f32139c61338738002e4 100644 (file)
@@ -94,7 +94,7 @@ namespace Mono.Security.Interface
                {
                }
 
-               volatile static MonoTlsSettings defaultSettings;
+               static MonoTlsSettings defaultSettings;
 
                public static MonoTlsSettings DefaultSettings {
                        get {
index 0855f8d6dd7935b632ecaeb49750330feb9e1efd..7472e719400329eba68ad4a29c2d59c870c13a06 100644 (file)
@@ -89,7 +89,7 @@ namespace Mono.Security.Protocol.Ntlm {
                public Type3Message (Type2Message type2) : base (3)
                {
                        _type2 = type2;
-                       _level = DefaultAuthLevel;
+                       _level = NtlmSettings.DefaultAuthLevel;
                        _challenge = (byte[]) type2.Nonce.Clone ();
 
                        _domain = type2.TargetName;
@@ -269,11 +269,13 @@ namespace Mono.Security.Protocol.Ntlm {
                                        throw new InvalidOperationException (
                                                "Refusing to use legacy-mode LM/NTLM authentication " +
                                                        "unless explicitly enabled using DefaultAuthLevel.");
-                               
+
+                               #pragma warning disable 618
                                using (var legacy = new ChallengeResponse (_password, _challenge)) {
                                        lm = legacy.LM;
                                        ntlm = legacy.NT;
                                }
+                               #pragma warning restore 618
                        } else {
                                ChallengeResponse2.Compute (_type2, _level, _username, _password, _domain, out lm, out ntlm);
                        }
index d59769b0a7e0774f6daf3ee6acfbd08c1f8f566b..f92ad900e84de0dc65e7169d767c6164d76139da 100644 (file)
@@ -131,6 +131,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
 
                private X509Certificate FindParentCertificate (X509Certificate cert)
                {
+                       #pragma warning disable 618
                        // This certificate is the root certificate
                        if (cert.GetName () == cert.GetIssuerName ())
                                return null;
@@ -140,6 +141,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
                                        return certificate;
                        }
                        return null;
+                       #pragma warning restore 618
                }
 
                #endregion
index e194013a637afde4ebff8792f8cc2e8884ba4381..30270c801c8d6afc88219ea863d2957d9457632a 100644 (file)
@@ -597,7 +597,7 @@ namespace Mono.Security.Protocol.Tls
                        try {
                                SendAlert(alert);
                        } catch (Exception alertEx) {
-                               ex = new IOException (string.Format ("Error while sending TLS Alert ({0}:{1}): {2}", alert.Level, alert.Description, ex), ex);
+                               ex = new IOException (string.Format ("Error while sending TLS Alert ({0}:{1}): {2}", alert.Level, alert.Description, ex), alertEx);
                        }
                }
 
index b043f7e18cf090fb4ed47da41da29f4437c89086..f8207297cb365599e88d4fcaf7847afa877f14d9 100644 (file)
@@ -132,7 +132,6 @@ namespace Mono.Security.Protocol.Tls
                                        throw new TlsException(AlertDescription.UnexpectedMessage, String.Format(CultureInfo.CurrentUICulture,
                                                                                                                 "Unknown server handshake message received ({0})", 
                                                                                                                 type.ToString()));
-                                       break;
                        }
                        throw new TlsException (AlertDescription.HandshakeFailiure, String.Format ("Protocol error, unexpected protocol transition from {0} to {1}", last, type));
                }
index 1f37bc47589c7cebf77d7b621cd499d095f0c3db..224c4e3c3151cdec714bb104c72d67e45479c9e1 100644 (file)
@@ -85,37 +85,6 @@ namespace Mono.Net.Security
                readonly MonoTlsStream tlsStream;
                readonly HttpWebRequest request;
 
-               static bool is_macosx;
-               static bool is_mobile;
-#if !MOBILE
-               static X509RevocationMode revocation_mode;
-#endif
-
-               static ChainValidationHelper ()
-               {
-#if MONOTOUCH
-                       is_macosx = true;
-                       is_mobile = true;
-#elif MONODROID
-                       is_macosx = false;
-                       is_mobile = true;
-#else
-                       is_macosx = System.IO.File.Exists (OSX509Certificates.SecurityLibrary);
-                       is_mobile = false;
-#endif
-
-#if !MOBILE
-                       revocation_mode = X509RevocationMode.NoCheck;
-                       try {
-                               string str = Environment.GetEnvironmentVariable ("MONO_X509_REVOCATION_MODE");
-                               if (String.IsNullOrEmpty (str))
-                                       return;
-                               revocation_mode = (X509RevocationMode)Enum.Parse (typeof(X509RevocationMode), str, true);
-                       } catch {
-                       }
-#endif
-               }
-
                internal static ICertificateValidator GetDefaultValidator (MonoTlsProvider provider, MonoTlsSettings settings)
                {
                        if (settings == null)
index 4a7b792ea7056a083f87eec7e32992244b1b4903..df560b7dd7aa121266ed3675e17f00993ddde850 100644 (file)
@@ -83,8 +83,6 @@ namespace Mono.Net.Security
                #region Fields
 
                SslStreamBase ssl_stream;
-               MonoTlsProvider provider;
-               MonoTlsSettings settings;
                ICertificateValidator certificateValidator;
 
                #endregion // Fields
@@ -94,9 +92,7 @@ namespace Mono.Net.Security
                public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
                        : base (innerStream, leaveInnerStreamOpen)
                {
-                       this.provider = provider;
-                       this.settings = settings;
-                       this.certificateValidator = ChainValidationHelper.GetDefaultValidator (provider, settings);
+                       certificateValidator = ChainValidationHelper.GetDefaultValidator (provider, settings);
                }
                #endregion // Constructors
 
index 762c74aba1a34cf73f7d296edadec765fc4a05c0..f0a0be39e0eb547f4e595696cd1c217aaea2b23e 100644 (file)
@@ -44,7 +44,6 @@ namespace Mono.Net.Security
        internal static class SystemCertificateValidator
        {
                static bool is_macosx;
-               static bool is_mobile;
 #if !MOBILE
                static X509RevocationMode revocation_mode;
 #endif
@@ -53,13 +52,10 @@ namespace Mono.Net.Security
                {
 #if MONOTOUCH
                        is_macosx = true;
-                       is_mobile = true;
 #elif MONODROID
                        is_macosx = false;
-                       is_mobile = true;
 #else
                        is_macosx = System.IO.File.Exists (OSX509Certificates.SecurityLibrary);
-                       is_mobile = false;
 #endif
 
 #if !MOBILE