internal static ChainValidationHelper Create(MobileTlsProvider provider, ref MonoTlsSettings settings, MonoTlsStream stream)
        {
            var helper = new ChainValidationHelper(null, provider, settings, true, stream);

            settings = helper.settings;
            return(helper);
        }
Ejemplo n.º 2
0
 public SslStream(Stream innerStream, bool leaveInnerStreamOpen)
     : base(innerStream, leaveInnerStreamOpen)
 {
     provider = GetProvider();
     settings = MonoTlsSettings.CopyDefaultSettings();
     impl     = provider.CreateSslStream(this, innerStream, leaveInnerStreamOpen, settings);
 }
Ejemplo n.º 3
0
 internal SslStream(Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
     : base(innerStream, leaveInnerStreamOpen)
 {
     this.provider    = (MNS.MobileTlsProvider)provider;
     this.settings    = settings.Clone();
     explicitSettings = true;
     impl             = this.provider.CreateSslStream(this, innerStream, leaveInnerStreamOpen, settings);
 }
Ejemplo n.º 4
0
 public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
     : base(innerStream, leaveInnerStreamOpen)
 {
     provider = GetProvider();
     settings = MonoTlsSettings.CopyDefaultSettings();
     SetAndVerifyValidationCallback(userCertificateValidationCallback);
     SetAndVerifySelectionCallback(userCertificateSelectionCallback);
     impl = provider.CreateSslStream(this, innerStream, leaveInnerStreamOpen, settings);
 }
        ChainValidationHelper(SslStream owner, MobileTlsProvider provider, MonoTlsSettings settings, bool cloneSettings, MonoTlsStream stream)
        {
            if (settings == null)
            {
                settings = MonoTlsSettings.CopyDefaultSettings();
            }
            if (cloneSettings)
            {
                settings = settings.CloneWithValidator(this);
            }
            if (provider == null)
            {
                provider = MonoTlsProviderFactory.GetProviderInternal();
            }

            this.provider  = provider;
            this.settings  = settings;
            this.tlsStream = stream;

            if (owner != null)
            {
                this.owner = new WeakReference <SslStream> (owner);
            }

            var fallbackToSPM = false;

            if (settings != null)
            {
                certValidationCallback = GetValidationCallback(settings);
                certSelectionCallback  = Private.CallbackHelpers.MonoToInternal(settings.ClientCertificateSelectionCallback);
                fallbackToSPM          = settings.UseServicePointManagerCallback ?? stream != null;
            }

            if (stream != null)
            {
                this.request = stream.Request;

                if (certValidationCallback == null)
                {
                    certValidationCallback = request.ServerCertValidationCallback;
                }
                if (certSelectionCallback == null)
                {
                    certSelectionCallback = new LocalCertSelectionCallback(DefaultSelectionCallback);
                }

                if (settings == null)
                {
                    fallbackToSPM = true;
                }
            }

            if (fallbackToSPM && certValidationCallback == null)
            {
                certValidationCallback = ServicePointManager.ServerCertValidationCallback;
            }
        }
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
                                         MSI.MonoTlsSettings settings, MobileTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            SslStream = owner;
            Settings  = settings;
            Provider  = provider;

            readBuffer  = new BufferOffsetSize2(16500);
            writeBuffer = new BufferOffsetSize2(16384);
            operation   = Operation.None;
        }
#pragma warning disable 618

        internal static ChainValidationHelper GetInternalValidator(SslStream owner, MobileTlsProvider provider, MonoTlsSettings settings)
        {
            if (settings == null)
            {
                return(new ChainValidationHelper(owner, provider, null, false, null));
            }
            if (settings.CertificateValidator != null)
            {
                return((ChainValidationHelper)settings.CertificateValidator);
            }
            return(new ChainValidationHelper(owner, provider, settings, false, null));
        }
Ejemplo n.º 8
0
        public SslStream(Stream innerStream, bool leaveInnerStreamOpen)
            : base(innerStream, leaveInnerStreamOpen)
        {
#if WASM
            try {
                provider = GetProvider();
            } catch (Exception ex) {
                throw new PlatformNotSupportedException("System.Net.Security.SslStream is not supported on the current platform.", ex);
            }
#else
            provider = GetProvider();
#endif
            settings = MonoTlsSettings.CopyDefaultSettings();
            impl     = provider.CreateSslStream(this, innerStream, leaveInnerStreamOpen, settings);
        }
Ejemplo n.º 9
0
        public MonoTlsStream(HttpWebRequest request, NetworkStream networkStream)
        {
#if SECURITY_DEP
            this.request       = request;
            this.networkStream = networkStream;

            settings = request.TlsSettings;
            provider = request.TlsProvider ?? MonoTlsProviderFactory.GetProviderInternal();
            status   = WebExceptionStatus.SecureChannelFailure;

            ChainValidationHelper.Create(provider, ref settings, this);
#else
            status = WebExceptionStatus.SecureChannelFailure;
            throw new PlatformNotSupportedException(EXCEPTION_MESSAGE);
#endif
        }
Ejemplo n.º 10
0
        public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
            : base(innerStream, leaveInnerStreamOpen)
        {
#if WASM
            try {
                provider = GetProvider();
            } catch (Exception ex) {
                throw new PlatformNotSupportedException("System.Net.Security.SslStream is not supported on the current platform.", ex);
            }
#else
            provider = GetProvider();
#endif
            settings = MonoTlsSettings.CopyDefaultSettings();
            SetAndVerifyValidationCallback(userCertificateValidationCallback);
            SetAndVerifySelectionCallback(userCertificateSelectionCallback);
            impl = provider.CreateSslStream(this, innerStream, leaveInnerStreamOpen, settings);
        }
Ejemplo n.º 11
0
        internal static IMonoSslStream CreateMonoSslStream(Stream innerStream, bool leaveInnerStreamOpen, MNS.MobileTlsProvider provider, MonoTlsSettings settings)
        {
            var sslStream = new SslStream(innerStream, leaveInnerStreamOpen, provider, settings);

            return(sslStream.Impl);
        }
Ejemplo n.º 12
0
 public AppleTlsStream(Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
                       MonoTlsSettings settings, MNS.MobileTlsProvider provider)
     : base(innerStream, leaveInnerStreamOpen, owner, settings, provider)
 {
 }