Esempio n. 1
0
 internal static HttpWebRequest CreateHttpsRequest(Uri requestUri, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
 {
     lock (locker) {
         var internalProvider = provider != null ? new Private.MonoTlsProviderWrapper(provider) : null;
         return(new HttpWebRequest(requestUri, internalProvider, settings));
     }
 }
Esempio n. 2
0
 internal static HttpListener CreateHttpListener(X509Certificate certificate, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
 {
     lock (locker) {
         var internalProvider = provider != null ? new Private.MonoTlsProviderWrapper(provider) : null;
         return(new HttpListener(certificate, internalProvider, settings));
     }
 }
Esempio n. 3
0
 internal HttpListener(X509Certificate certificate, MSI.MonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
     : this()
 {
     this.certificate = certificate;
     this.tlsProvider = tlsProvider;
     this.tlsSettings = tlsSettings;
 }
Esempio n. 4
0
        static IMonoTlsProvider CreateDefaultProvider()
        {
#if SECURITY_DEP
            MSI.MonoTlsProvider provider = null;
#if MONO_FEATURE_NEW_SYSTEM_SOURCE
            /*
             * This is a hack, which is used in the Mono.Security.Providers.NewSystemSource
             * assembly, which will provide a "fake" System.dll.  Use the public Mono.Security
             * API to get the "real" System.dll's provider via reflection, then wrap it with
             * the "fake" version's perceived view.
             *
             * NewSystemSource needs to compile MonoTlsProviderFactory.cs, IMonoTlsProvider.cs,
             * MonoTlsProviderWrapper.cs and CallbackHelpers.cs from this directory and only these.
             */
            provider = MSI.MonoTlsProviderFactory.GetProvider();
#else
            provider = CreateDefaultProviderImpl();
#endif
            if (provider != null)
            {
                return(new Private.MonoTlsProviderWrapper(provider));
            }
#endif
            return(null);
        }
 static MSI.MonoTlsProvider CreateDefaultProviderImpl()
 {
     MSI.MonoTlsProvider provider = null;
     if (MSI.MonoTlsProviderFactory._PrivateFactoryDelegate != null)
     {
         provider = MSI.MonoTlsProviderFactory._PrivateFactoryDelegate();
     }
     return(provider);
 }
Esempio n. 6
0
 static MSI.MonoTlsProvider GetTlsProvider()
 {
     lock (locker) {
         if (provider == null)
         {
             provider = new AppleTlsProvider();
         }
         return(provider);
     }
 }
Esempio n. 7
0
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen,
                                         MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            Settings = settings;
            Provider = provider;

            readBuffer  = new BufferOffsetSize2(16834);
            writeBuffer = new BufferOffsetSize2(16384);
        }
Esempio n. 8
0
        static IMonoTlsProvider CreateDefaultProvider()
        {
#if SECURITY_DEP
            MSI.MonoTlsProvider provider = CreateDefaultProviderImpl();
            if (provider != null)
            {
                return(new Private.MonoTlsProviderWrapper(provider));
            }
#endif
            return(null);
        }
Esempio n. 9
0
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
                                         MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            SslStream = owner;
            Settings  = settings;
            Provider  = provider;

            readBuffer  = new BufferOffsetSize2(16500);
            writeBuffer = new BufferOffsetSize2(16384);
            operation   = Operation.None;
        }
Esempio n. 10
0
 internal SslStream CreateSslStream(Stream innerStream, bool ownsStream, MSI.MonoRemoteCertificateValidationCallback callback)
 {
     lock (registry) {
         if (tlsProvider == null)
         {
             tlsProvider = MSI.MonoTlsProviderFactory.GetProvider();
         }
         if (tlsSettings == null)
         {
             tlsSettings = MSI.MonoTlsSettings.CopyDefaultSettings();
         }
         if (tlsSettings.RemoteCertificateValidationCallback == null)
         {
             tlsSettings.RemoteCertificateValidationCallback = callback;
         }
         var sslStream = tlsProvider.CreateSslStream(innerStream, ownsStream, tlsSettings);
         return(sslStream.SslStream);
     }
 }
Esempio n. 11
0
        static MSI.MonoTlsProvider CreateDefaultProviderImpl()
        {
            MSI.MonoTlsProvider provider = null;
            var type = Environment.GetEnvironmentVariable("XA_TLS_PROVIDER");

            switch (type)
            {
            case null:
            case "default":
            case "legacy":
                return(new LegacyTlsProvider());

#if MONO_FEATURE_BTLS
            case "btls":
                if (!IsBtlsSupported())
                {
                    throw new NotSupportedException("BTLS in not supported!");
                }
                return(new MonoBtlsProvider());
#endif
            default:
                throw new NotSupportedException(string.Format("Invalid TLS Provider: `{0}'.", provider));
            }
        }
Esempio n. 12
0
        static MSI.MonoTlsProvider CreateDefaultProviderImpl()
        {
#if MONODROID
            MSI.MonoTlsProvider provider = null;
            var type = Environment.GetEnvironmentVariable("XA_TLS_PROVIDER");
            switch (type)
            {
            case null:
            case "default":
            case "legacy":
                return(new LegacyTlsProvider());

#if MONO_FEATURE_BTLS
            case "btls":
                if (!IsBtlsSupported())
                {
                    throw new NotSupportedException("BTLS in not supported!");
                }
                return(new MonoBtlsProvider());
#endif
            default:
                throw new NotSupportedException(string.Format("Invalid TLS Provider: `{0}'.", provider));
            }
#elif ONLY_APPLETLS || MONOTOUCH || XAMMAC
            return(new AppleTlsProvider());
#else
            var type = Environment.GetEnvironmentVariable("MONO_TLS_PROVIDER");
            if (string.IsNullOrEmpty(type))
            {
                type = "default";
            }

            switch (type)
            {
            case "default":
#if MONO_FEATURE_APPLETLS
                if (Platform.IsMacOS)
                {
                    goto case "apple";
                }
#endif
#if MONO_FEATURE_BTLS
                if (IsBtlsSupported())
                {
                    goto case "btls";
                }
#endif
                goto case "legacy";

#if MONO_FEATURE_APPLETLS
            case "apple":
                return(new AppleTlsProvider());
#endif
#if MONO_FEATURE_BTLS
            case "btls":
                return(new MonoBtlsProvider());
#endif
            case "legacy":
                return(new Mono.Net.Security.LegacyTlsProvider());
            }

            return(LookupProvider(type, true));
#endif
        }
Esempio n. 13
0
		public MonoTlsProviderWrapper (MSI.MonoTlsProvider provider)
		{
			this.provider = provider;
		}
Esempio n. 14
0
 internal static void InstallProvider(MSI.MonoTlsProvider provider)
 {
     lock (locker) {
         currentProvider = new Private.MonoTlsProviderWrapper(provider);
     }
 }
 public MonoTlsProviderWrapper(MSI.MonoTlsProvider provider)
 {
     this.provider = provider;
 }