コード例 #1
0
ファイル: OldTlsProvider.cs プロジェクト: Profit0004/mono
		public override IMonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MonoTlsSettings settings = null)
		{
			var impl = new MNS.Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
			return new MNS.Private.MonoSslStreamImpl (impl);
		}
コード例 #2
0
        MSI.MonoTlsSettings GetSettings(ConnectionParameters parameters, bool requireSettings)
        {
            MSI.MonoTlsSettings settings = null;
            if (requireSettings)
            {
                settings = MSI.MonoTlsSettings.CopyDefaultSettings();
            }
            if (parameters.ValidationParameters != null && parameters.ValidationParameters.TrustedRoots != null)
            {
                if (settings == null)
                {
                    settings = MSI.MonoTlsSettings.CopyDefaultSettings();
                }
                settings.TrustAnchors = new X509CertificateCollection();
                foreach (var trustedRoot in parameters.ValidationParameters.TrustedRoots)
                {
                    var trustedRootCert = ResourceManager.GetCertificate(trustedRoot);
                    settings.TrustAnchors.Add(trustedRootCert);
                }
            }
            if ((parameters.SslStreamFlags & SslStreamFlags.CleanShutdown) != 0)
            {
                if (settings == null)
                {
                    settings = MSI.MonoTlsSettings.CopyDefaultSettings();
                }
                var setup = DependencyInjector.Get <IMonoConnectionFrameworkSetup> ();
                setup.SendCloseNotify(settings, true);
            }

            return(settings);
        }
コード例 #3
0
        protected sealed override async Task <ISslStream> Start(TestContext ctx, Stream stream, CancellationToken cancellationToken)
        {
            UserSettings userSettings = new UserSettings();

            if (SupportsInstrumentation && InstrumentationProvider != null)
            {
                var instrumentation = InstrumentationProvider.CreateInstrument(ctx);
                if (instrumentation != null && instrumentation.HasSettingsInstrument)
                {
                    userSettings = instrumentation.SettingsInstrument.UserSettings;
                }
                userSettings.Instrumentation = instrumentation;
            }

            GetSettings(userSettings);

            if (ConnectionProvider.IsNewTls)
            {
                settings = new MSI.MonoTlsSettings();
                settings.UserSettings = userSettings;
            }

            monoSslStream = await Start(ctx, stream, settings, cancellationToken);

            return(monoSslStream);
        }
コード例 #4
0
        public AppleTlsContext(
            MobileAuthenticatedStream parent, MonoTlsSettings settings,
            AppleTlsProvider provider, bool serverMode, string targetHost,
            SSA.SslProtocols enabledProtocols, X509Certificate serverCertificate,
            X509CertificateCollection clientCertificates, bool askForClientCert)
        {
            this.parent = parent;
            this.settings = settings;
            this.provider = provider;
            this.serverMode = serverMode;
            this.targetHost = targetHost;
            this.enabledProtocols = enabledProtocols;
            this.serverCertificate = serverCertificate;
            this.clientCertificates = clientCertificates;
            this.askForClientCert = askForClientCert;

            handle = GCHandle.Alloc (this);
            connectionId = GCHandle.ToIntPtr (handle);
            readFunc = NativeReadCallback;
            writeFunc = NativeWriteCallback;

            // a bit higher than the default maximum fragment size
            readBuffer = new byte [16384];
            writeBuffer = new byte [16384];

            certificateValidator = CertificateValidationHelper.GetDefaultValidator (settings, provider);

            if (IsServer) {
                if (serverCertificate == null)
                    throw new ArgumentNullException ("serverCertificate");
            }
        }
コード例 #5
0
        public SslStream CreateSslStream(TestContext ctx, Stream stream, ConnectionParameters parameters, bool server)
        {
            var settings = new MSI.MonoTlsSettings();

            if (parameters is MonoConnectionParameters monoParams)
            {
                if (monoParams.ClientCiphers != null)
                {
                    settings.EnabledCiphers = monoParams.ClientCiphers.ToArray();
                }

                if (!server && monoParams.ClientCertificateIssuers != null)
                {
                    if (clientCertIssuersProp == null)
                    {
                        ctx.AssertFail("MonoTlsSettings.ClientCertificateIssuers is not supported!");
                    }
                    clientCertIssuersProp.SetValue(settings, monoParams.ClientCertificateIssuers);
                }
            }

            if (server)
            {
                CallbackHelpers.AddCertificateValidator(settings, parameters.ServerCertificateValidator);
            }
            else
            {
                CallbackHelpers.AddCertificateValidator(settings, parameters.ClientCertificateValidator);
                CallbackHelpers.AddCertificateSelector(settings, parameters.ClientCertificateSelector);
            }

            return(tlsProvider.CreateSslStream(stream, false, settings).SslStream);
        }
コード例 #6
0
		public override IMonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MonoTlsSettings settings = null)
		{
			return new MonoBtlsStream (
				innerStream, leaveInnerStreamOpen, settings, this);
		}
コード例 #7
0
		internal static MonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MonoTlsProvider provider, MonoTlsSettings settings = null)
		{
			var stream = new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, provider, settings);
			return new MonoSslStreamImpl (stream);
		}
コード例 #8
0
		internal static MonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			ICertificateValidator certificateValidator,
			MonoTlsSettings settings = null)
		{
			var stream = new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, certificateValidator, settings);
			return new MonoSslStreamImpl (stream);
		}
コード例 #9
0
#pragma warning disable 618

		internal static ICertificateValidator GetInternalValidator (MonoTlsProvider provider, MonoTlsSettings settings)
		{
			if (settings == null)
				return new ChainValidationHelper (provider, null, false, null, null);
			if (settings.CertificateValidator != null)
				return settings.CertificateValidator;
			return new ChainValidationHelper (provider, settings, false, null, null);
		}
コード例 #10
0
ファイル: DotNetTlsProvider.cs プロジェクト: JokerGITHUB/mono
		public override IMonoTlsContext CreateTlsContext (
			string hostname, bool serverMode, TlsProtocols protocolFlags,
			X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
			bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
			MonoTlsSettings settings)
		{
			throw new NotSupportedException ();
		}
コード例 #11
0
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings, AppleTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            Settings = settings;
            Provider = provider;

            readBuffer = new BufferOffsetSize (new byte [16384], 0, 0);
            writeBuffer = new BufferOffsetSize (new byte [16384], 0, 0);
        }
コード例 #12
0
        internal static void AddCertificateValidator(MSI.MonoTlsSettings settings, CertificateValidator validator)
        {
            if (validator == null)
            {
                return;
            }

            settings.RemoteCertificateValidationCallback = (s, c, ch, e) => {
                return(validator.ValidationCallback(s, c, ch, (SslPolicyErrors)e));
            };
        }
コード例 #13
0
        internal static void AddCertificateSelector(MSI.MonoTlsSettings settings, CertificateSelector selector)
        {
            if (selector == null)
            {
                return;
            }

            settings.ClientCertificateSelectionCallback = (t, lc, rc, ai) => {
                return(selector.SelectionCallback(null, t, lc, rc, ai));
            };
        }
コード例 #14
0
ファイル: MonoTlsStream.cs プロジェクト: ancailliau/mono
		public MonoTlsStream (HttpWebRequest request, NetworkStream networkStream)
		{
			this.request = request;
			this.networkStream = networkStream;

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

			/*validationHelper =*/ ChainValidationHelper.Create (provider.Provider, ref settings, this);
		}
コード例 #15
0
		internal static MSI.ICertificateValidator GetCertificateValidator (ICertificateValidator validator)
		{
			if (validator == null)
				return null;

			var settings = new MSI.MonoTlsSettings ();
			settings.ServerCertificateValidationCallback = (s, c, ch, e) => {
				return ((CertificateValidator)validator).ValidationCallback (s, c, ch, (SslPolicyErrors)e);
			};
			return MSI.CertificateValidationHelper.CreateDefaultValidator (settings);
		}
コード例 #16
0
        protected sealed override async Task <ISslStream> Start(TestContext ctx, Stream stream, CancellationToken cancellationToken)
        {
            if (ConnectionProvider.SupportsMonoExtensions)
            {
                settings = new MSI.MonoTlsSettings();
                GetSettings(ctx, settings);
            }

            monoSslStream = await Start(ctx, stream, settings, cancellationToken);

            return(monoSslStream);
        }
コード例 #17
0
ファイル: NewTlsProvider.cs プロジェクト: zhufengGNSS/mono
        internal override MSI.IMonoTlsContext CreateTlsContext(
            string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
            SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
            bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
            MSI.MonoTlsSettings settings)
        {
            var config = TlsProviderFactory.CreateTlsConfiguration(
                hostname, serverMode, protocolFlags, serverCertificate,
                remoteCertRequired, settings);

            return(new TlsContextWrapper(config, serverMode));
        }
コード例 #18
0
		public TlsConfiguration (TlsProtocols protocols, MonoTlsSettings settings, string targetHost)
		{
			supportedProtocols = protocols;
			requestedProtocol = CheckProtocol (settings, ref supportedProtocols, false);
			TlsSettings = settings;
			TargetHost = targetHost;

			if (settings != null)
				UserSettings = (UserSettings)settings.UserSettings;
			if (UserSettings == null)
				UserSettings = new UserSettings ();

			RenegotiationFlags = DefaultRenegotiationFlags;
		}
コード例 #19
0
        protected override void GetSettings(TestContext ctx, MSI.MonoTlsSettings settings)
        {
            if (MonoParameters != null && MonoParameters.ClientCiphers != null)
            {
                settings.EnabledCiphers = MonoParameters.ClientCiphers.ToArray();
            }

            if (MonoParameters != null)
            {
                                #if FIXME
                settings.RequestCipherSuites = MonoParameters.ClientCiphers;
                settings.NamedCurve          = MonoParameters.ClientNamedCurve;
                                #endif
            }
        }
コード例 #20
0
		public TlsConfiguration (TlsProtocols protocols, MonoTlsSettings settings, MX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
		{
			supportedProtocols = protocols;
			requestedProtocol = CheckProtocol (settings, ref supportedProtocols, true);
			TlsSettings = settings;
			Certificate = certificate;
			PrivateKey = privateKey;

			if (settings != null)
				UserSettings = (UserSettings)settings.UserSettings;
			if (UserSettings == null)
				UserSettings = new UserSettings ();

			RenegotiationFlags = DefaultRenegotiationFlags;
		}
コード例 #21
0
ファイル: SslStream.cs プロジェクト: Profit0004/mono
		internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, EncryptionPolicy encryptionPolicy, MonoTlsProvider provider, MonoTlsSettings settings)
			: base (innerStream, leaveInnerStreamOpen)
		{
			if (encryptionPolicy != EncryptionPolicy.RequireEncryption && encryptionPolicy != EncryptionPolicy.AllowNoEncryption && encryptionPolicy != EncryptionPolicy.NoEncryption)
				throw new ArgumentException (SR.GetString (SR.net_invalid_enum, "EncryptionPolicy"), "encryptionPolicy");

			var validationHelper = MNS.ChainValidationHelper.CloneWithCallbackWrapper (provider, ref settings, myUserCertValidationCallbackWrapper);

			LocalCertSelectionCallback selectionCallback = null;
			if (validationHelper.HasCertificateSelectionCallback)
				selectionCallback = validationHelper.SelectClientCertificate;

			var internalProvider = new MNS.Private.MonoTlsProviderWrapper (provider);
			_Configuration = new MyConfiguration (internalProvider, settings, this);
			_SslState = new SslState (innerStream, null, selectionCallback, encryptionPolicy, _Configuration);
		}
コード例 #22
0
		public static MonoNewTlsStream CreateClient (
			Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
			string targetHost, PSSCX.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
		{
			var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);

			try {
				stream.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
			} catch (Exception ex) {
				var tlsEx = stream.LastError;
				if (tlsEx != null)
					throw new AggregateException (ex, tlsEx);
				throw;
			}
			return stream;
		}
コード例 #23
0
        MSI.MonoTlsSettings GetSettings(ConnectionParameters parameters)
        {
            MSI.MonoTlsSettings settings = null;
            if (parameters.ValidationParameters != null && parameters.ValidationParameters.TrustedRoots != null)
            {
                settings = MSI.MonoTlsSettings.CopyDefaultSettings();
                settings.TrustAnchors = new X509CertificateCollection();
                foreach (var trustedRoot in parameters.ValidationParameters.TrustedRoots)
                {
                    var trustedRootCert = ResourceManager.GetCertificate(trustedRoot);
                    settings.TrustAnchors.Add(trustedRootCert);
                }
            }

            return(settings);
        }
コード例 #24
0
ファイル: DotNetTlsProvider.cs プロジェクト: JokerGITHUB/mono
		public override MonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MonoTlsSettings settings = null)
		{
			if (settings != null)
				throw new NotSupportedException ("Mono-specific API Extensions not available.");

			RemoteCertificateValidationCallback validation_callback = null;
			LocalCertificateSelectionCallback selection_callback = null;

			if (settings != null) {
				validation_callback = ConvertCallback (settings.RemoteCertificateValidationCallback);
				selection_callback = ConvertCallback (settings.ClientCertificateSelectionCallback);
			}

			return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, validation_callback, selection_callback);
		}
コード例 #25
0
        public MonoSslStream CreateServerStream(Stream stream, ConnectionParameters parameters)
        {
            var settings    = new MSI.MonoTlsSettings();
            var certificate = parameters.ServerCertificate;

            var protocol = GetProtocol(parameters, true);

            CallbackHelpers.AddCertificateValidator(settings, parameters.ServerCertificateValidator);

            var askForCert = parameters.AskForClientCertificate || parameters.RequireClientCertificate;

            var sslStream = tlsProvider.CreateSslStream(stream, false, settings);

            sslStream.AuthenticateAsServer(certificate, askForCert, protocol, false);

            return(new MonoSslStream(sslStream));
        }
コード例 #26
0
        public HttpWebRequest CreateWebRequest(Uri uri, ConnectionParameters parameters)
        {
            MSI.MonoTlsSettings settings = null;
            if (parameters.ValidationParameters != null && parameters.ValidationParameters.TrustedRoots != null)
            {
                settings = MSI.MonoTlsSettings.CopyDefaultSettings();
                settings.TrustAnchors = new X509CertificateCollection();
                foreach (var trustedRoot in parameters.ValidationParameters.TrustedRoots)
                {
                    var trustedRootCert = ResourceManager.GetCertificate(trustedRoot);
                    settings.TrustAnchors.Add(trustedRootCert);
                }
            }

            var setup = DependencyInjector.Get <IMonoConnectionFrameworkSetup> ();

            return(setup.CreateHttpsRequest(uri, tlsProvider, settings));
        }
コード例 #27
0
        public TlsConfiguration(MSI.TlsProtocols protocols, MSI.MonoTlsSettings settings, string targetHost)
        {
            supportedProtocols = protocols;
            requestedProtocol  = CheckProtocol(settings, ref supportedProtocols, false);
            TlsSettings        = settings;
            TargetHost         = targetHost;

            if (settings != null)
            {
                UserSettings = (UserSettings)settings.UserSettings;
            }
            if (UserSettings == null)
            {
                UserSettings = new UserSettings(settings);
            }

            RenegotiationFlags = DefaultRenegotiationFlags;
        }
コード例 #28
0
        public TlsConfiguration(MSI.TlsProtocols protocols, MSI.MonoTlsSettings settings, MX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
        {
            supportedProtocols = protocols;
            requestedProtocol  = CheckProtocol(settings, ref supportedProtocols, true);
            TlsSettings        = settings;
            Certificate        = certificate;
            PrivateKey         = privateKey;

            if (settings != null)
            {
                UserSettings = (UserSettings)settings.UserSettings;
            }
            if (UserSettings == null)
            {
                UserSettings = new UserSettings(settings);
            }

            RenegotiationFlags = DefaultRenegotiationFlags;
        }
コード例 #29
0
ファイル: SslStream.cs プロジェクト: jdgiotta/mono
		internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, EncryptionPolicy encryptionPolicy, MonoTlsSettings settings)
			: base (innerStream, leaveInnerStreamOpen)
		{
#if MARTIN_FIXME
			if (encryptionPolicy != EncryptionPolicy.RequireEncryption && encryptionPolicy != EncryptionPolicy.AllowNoEncryption && encryptionPolicy != EncryptionPolicy.NoEncryption)
				throw new ArgumentException (SR.GetString (SR.net_invalid_enum, "EncryptionPolicy"), "encryptionPolicy");

			var validationHelper = ChainValidationHelper.CloneWithCallbackWrapper (ref settings, myUserCertValidationCallbackWrapper);

			LocalCertSelectionCallback selectionCallback = null;
			if (validationHelper.HasCertificateSelectionCallback)
				selectionCallback = validationHelper.SelectClientCertificate;

			_Configuration = new MyConfiguration (settings, this);
			_SslState = new SslState (innerStream, null, selectionCallback, encryptionPolicy, _Configuration);
#else
			throw new NotImplementedException ();
#endif
		}
コード例 #30
0
ファイル: MonoServer.cs プロジェクト: Roykens/web-tests
        protected override void GetSettings(TestContext ctx, MSI.MonoTlsSettings settings)
        {
#if FIXME
            if (Parameters.RequireClientCertificate)
            {
                settings.RequireClientCertificate = settings.AskForClientCertificate = true;
            }
            else if (Parameters.AskForClientCertificate)
            {
                settings.AskForClientCertificate = true;
            }
#endif

            if (MonoParameters == null)
            {
                return;
            }

            if (MonoParameters.ServerCiphers != null)
            {
                settings.EnabledCiphers = MonoParameters.ServerCiphers.ToArray();
            }

            if (MonoParameters.ClientCertificateIssuers != null)
            {
                if (clientCertIssuersProp == null)
                {
                    ctx.AssertFail("MonoTlsSettings.ClientCertificateIssuers is not supported!");
                }
                clientCertIssuersProp.SetValue(settings, MonoParameters.ClientCertificateIssuers);
            }


            if (MonoParameters != null)
            {
                                #if FIXME
                settings.RequestCipherSuites = MonoParameters.ServerCiphers;
                settings.NamedCurve          = MonoParameters.ServerNamedCurve;
                                #endif
            }
        }
コード例 #31
0
        internal static ITlsConfiguration CreateTlsConfiguration(
            string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
            SSCX.X509Certificate serverCertificate, bool remoteCertRequired,
            MSI.MonoTlsSettings settings)
        {
            object[]          args;
            ITlsConfiguration config;

            if (serverMode)
            {
                var cert     = (PSSCX.X509Certificate2)serverCertificate;
                var monoCert = new MX.X509Certificate(cert.RawData);
                args = new object[] {
                    (MSI.TlsProtocols)protocolFlags,
                    (MSI.MonoTlsSettings)settings,
                    monoCert,
                    cert.PrivateKey
                };
            }
            else
            {
                args = new object[] {
                    (MSI.TlsProtocols)protocolFlags,
                    (MSI.MonoTlsSettings)settings,
                    hostname
                };
            }

            config = (ITlsConfiguration)CreateInstance(tlsConfigTypeName, args);

            if (serverMode && remoteCertRequired)
            {
                config.AskForClientCertificate = true;
            }

            return(config);
        }
コード例 #32
0
        static MSI.TlsProtocolCode CheckProtocol(MSI.MonoTlsSettings settings, ref MSI.TlsProtocols protocols, bool isServer)
        {
            if (settings != null && settings.EnabledProtocols != null)
            {
                protocols = (MSI.TlsProtocols)settings.EnabledProtocols.Value;
            }

            if (isServer)
            {
                protocols &= MSI.TlsProtocols.ServerMask;
            }
            else
            {
                protocols &= MSI.TlsProtocols.ClientMask;
            }

            if (protocols == 0)
            {
                throw new MSI.TlsException(MSI.AlertDescription.ProtocolVersion);
            }

            if ((protocols & MSI.TlsProtocols.Tls12) != 0)
            {
                return(MSI.TlsProtocolCode.Tls12);
            }
            if ((protocols & MSI.TlsProtocols.Tls11) != 0)
            {
                return(MSI.TlsProtocolCode.Tls11);
            }
            if ((protocols & MSI.TlsProtocols.Tls10) != 0)
            {
                return(MSI.TlsProtocolCode.Tls10);
            }

            throw new MSI.TlsException(MSI.AlertDescription.ProtocolVersion);
        }
コード例 #33
0
		ChainValidationHelper (MonoTlsProvider provider, MonoTlsSettings settings, bool cloneSettings, MonoTlsStream stream, ServerCertValidationCallbackWrapper callbackWrapper)
		{
			if (settings == null)
				settings = MonoTlsSettings.CopyDefaultSettings ();
			if (cloneSettings)
				settings = settings.CloneWithValidator (this);
			if (provider == null)
				provider = MonoTlsProviderFactory.GetProvider ();

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

			var fallbackToSPM = false;

			if (settings != null) {
				if (settings.RemoteCertificateValidationCallback != null) {
					var callback = Private.CallbackHelpers.MonoToPublic (settings.RemoteCertificateValidationCallback);
					certValidationCallback = new ServerCertValidationCallback (callback);
				}
				certSelectionCallback = Private.CallbackHelpers.MonoToInternal (settings.ClientCertificateSelectionCallback);
				fallbackToSPM = settings.UseServicePointManagerCallback ?? stream != null;
			}

			if (stream != null) {
				this.request = stream.Request;
				this.sender = 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;
		}
コード例 #34
0
ファイル: MonoTlsProviderFactory.cs プロジェクト: Numpsy/mono
		/*
		 * Create @HttpWebRequest with the specified @provider (may be null to use the default one).
		 * 
		 * NOTE: This needs to be written as "System.Uri" to avoid ambiguity with Mono.Security.Uri in the
		 *        mobile build.
		 * 
		 */
		public static HttpWebRequest CreateHttpsRequest (System.Uri requestUri, MonoTlsProvider provider, MonoTlsSettings settings = null)
		{
			return NoReflectionHelper.CreateHttpsRequest (requestUri, provider, settings);
		}
コード例 #35
0
 internal abstract IMonoTlsContext CreateTlsContext(
     string hostname, bool serverMode, TlsProtocols protocolFlags,
     X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
     bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
     MonoTlsSettings settings);
コード例 #36
0
 protected abstract void GetSettings(TestContext ctx, MSI.MonoTlsSettings settings);
コード例 #37
0
ファイル: MonoTlsProvider.cs プロジェクト: WELL-E/mono
		public abstract IMonoTlsContext CreateTlsContext (
			string hostname, bool serverMode, TlsProtocols protocolFlags,
			X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
			bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
			MonoTlsSettings settings);
コード例 #38
0
		internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, ICertificateValidator certificateValidator, MonoTlsSettings settings)
			: base (innerStream, leaveOpen, certificateValidator, EncryptionPolicy.RequireEncryption, settings)
		{
		}
コード例 #39
0
		MonoTlsSettings (MonoTlsSettings other)
		{
			RemoteCertificateValidationCallback = other.RemoteCertificateValidationCallback;
			ClientCertificateSelectionCallback = other.ClientCertificateSelectionCallback;
			checkCertName = other.checkCertName;
			checkCertRevocationStatus = other.checkCertRevocationStatus;
			UseServicePointManagerCallback = other.useServicePointManagerCallback;
			skipSystemValidators = other.skipSystemValidators;
			callbackNeedsChain = other.callbackNeedsChain;
			UserSettings = other.UserSettings;
			EnabledProtocols = other.EnabledProtocols;
			TrustAnchors = other.TrustAnchors;
			cloned = true;
		}
コード例 #40
0
 /*
  * Use this overloaded version in user code.
  */
 public static ICertificateValidator GetValidator(MonoTlsSettings settings)
 {
     return(GetDefaultValidator(null, settings));
 }
コード例 #41
0
ファイル: LegacySslStream.cs プロジェクト: JokerGITHUB/mono
		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);
		}
コード例 #42
0
 public static System.Net.HttpListener CreateHttpListener(System.Security.Cryptography.X509Certificates.X509Certificate certificate, MonoTlsProvider provider, MonoTlsSettings settings)
 {
     throw new NotImplementedException();
 }
コード例 #43
0
 internal MonoNewTlsStream(Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
     : base(innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
 {
     this.provider = provider;
 }
コード例 #44
0
 /*
  * Obtain a @IMonoSslStream instance.
  *
  */
 public abstract IMonoSslStream CreateSslStream(
     Stream innerStream, bool leaveInnerStreamOpen,
     MonoTlsSettings settings = null);
コード例 #45
0
 protected abstract Task <MonoSslStream> Start(TestContext ctx, Stream stream, MSI.MonoTlsSettings settings, CancellationToken cancellationToken);
コード例 #46
0
        protected override async Task <MonoSslStream> Start(TestContext ctx, Stream stream, MSI.MonoTlsSettings settings, CancellationToken cancellationToken)
        {
            var server = await ConnectionProvider.CreateServerStreamAsync(stream, Parameters, settings, cancellationToken);

            ctx.LogMessage("Successfully authenticated server.");

            return(server);
        }
コード例 #47
0
		internal static ICertificateValidator GetDefaultValidator (MonoTlsSettings settings)
		{
			var provider = MonoTlsProviderFactory.GetProvider ();
			if (settings == null)
				return new ChainValidationHelper (provider, null, false, null, null);
			if (settings.CertificateValidator != null)
				throw new NotSupportedException ();
			return new ChainValidationHelper (provider, settings, false, null, null);
		}
コード例 #48
0
 internal MonoNewTlsStream(Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
     : this(innerStream, false, provider, settings)
 {
 }
コード例 #49
0
        public async Task <MonoSslStream> CreateServerStreamAsync(Stream stream, ConnectionParameters parameters, MSI.MonoTlsSettings settings, CancellationToken cancellationToken)
        {
            var certificate = parameters.ServerCertificate;
            var protocol    = GetProtocol(parameters, true);

            CallbackHelpers.AddCertificateValidator(settings, parameters.ServerCertificateValidator);

            var askForCert    = parameters.AskForClientCertificate || parameters.RequireClientCertificate;
            var sslStream     = tlsProvider.CreateSslStream(stream, false, settings);
            var monoSslStream = new MonoSslStream(sslStream);

            await sslStream.AuthenticateAsServerAsync(certificate, askForCert, protocol, false).ConfigureAwait(false);

            return(monoSslStream);
        }
コード例 #50
0
		public MobileTlsStream (MonoTlsSettings settings, MobileTlsProvider provider)
		{
			this.settings = settings;
			this.provider = provider;
		}
コード例 #51
0
		public MonoTlsSettings CloneWithValidator (ICertificateValidator validator)
		{
			if (cloned) {
				this.certificateValidator = validator;
				return this;
			}

			var copy = new MonoTlsSettings (this);
			copy.certificateValidator = validator;
			return copy;
		}
コード例 #52
0
 public static System.Net.HttpWebRequest CreateHttpsRequest(Uri requestUri, MonoTlsProvider provider, MonoTlsSettings settings)
 {
     throw new NotImplementedException();
 }
コード例 #53
0
        public async Task <MonoSslStream> CreateClientStreamAsync(Stream stream, string targetHost, ConnectionParameters parameters, MSI.MonoTlsSettings settings, CancellationToken cancellationToken)
        {
            var protocol = GetProtocol(parameters, false);

            CallbackHelpers.AddCertificateValidator(settings, parameters.ClientCertificateValidator);
            CallbackHelpers.AddCertificateSelector(settings, parameters.ClientCertificateSelector);
            var clientCertificates = CallbackHelpers.GetClientCertificates(parameters);

            var sslStream     = tlsProvider.CreateSslStream(stream, false, settings);
            var monoSslStream = new MonoSslStream(sslStream);

            await sslStream.AuthenticateAsClientAsync(targetHost, clientCertificates, protocol, false).ConfigureAwait(false);

            return(monoSslStream);
        }
コード例 #54
0
		/*
		 * This is a hack which is used in SslStream - see ReferenceSources/SslStream.cs for details.
		 */
		internal static ChainValidationHelper CloneWithCallbackWrapper (MonoTlsProvider provider, ref MonoTlsSettings settings, ServerCertValidationCallbackWrapper wrapper)
		{
			var helper = (ChainValidationHelper)settings.CertificateValidator;
			if (helper == null)
				helper = new ChainValidationHelper (provider, settings, true, null, wrapper);
			else
				helper = new ChainValidationHelper (helper, provider, settings, wrapper);
			settings = helper.settings;
			return helper;
		}
コード例 #55
0
ファイル: MonoTlsProvider.cs プロジェクト: WELL-E/mono
		/*
		 * Obtain a @MonoSslStream instance.
		 *
		 */
		public abstract MonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MonoTlsSettings settings = null);
コード例 #56
0
		ChainValidationHelper (ChainValidationHelper other, MonoTlsProvider provider, MonoTlsSettings settings, ServerCertValidationCallbackWrapper callbackWrapper = null)
		{
			sender = other.sender;
			certValidationCallback = other.certValidationCallback;
			certSelectionCallback = other.certSelectionCallback;
			tlsStream = other.tlsStream;
			request = other.request;

			if (settings == null)
				settings = MonoTlsSettings.DefaultSettings;

			this.provider = provider;
			this.settings = settings.CloneWithValidator (this);
			this.callbackWrapper = callbackWrapper;
		}
コード例 #57
0
ファイル: MonoTlsProviderFactory.cs プロジェクト: Numpsy/mono
		public static HttpListener CreateHttpListener (X509Certificate certificate, MonoTlsProvider provider = null, MonoTlsSettings settings = null)
		{
			return (HttpListener)NoReflectionHelper.CreateHttpListener (certificate, provider, settings);
		}
コード例 #58
0
		internal static ChainValidationHelper Create (MonoTlsProvider provider, ref MonoTlsSettings settings, MonoTlsStream stream)
		{
			var helper = new ChainValidationHelper (provider, settings, true, stream, null);
			settings = helper.settings;
			return helper;
		}
コード例 #59
0
ファイル: MonoClient.cs プロジェクト: VimalKumarS/mono-tls
        protected override async Task <MonoSslStream> Start(TestContext ctx, Stream stream, MSI.MonoTlsSettings settings, CancellationToken cancellationToken)
        {
            ctx.LogMessage("Connected.");

            var targetHost = Parameters.TargetHost ?? EndPoint.HostName ?? EndPoint.Address;

            ctx.LogDebug(1, "Using '{0}' as target host.", targetHost);

            var client = await ConnectionProvider.CreateClientStreamAsync(stream, targetHost, Parameters, settings, cancellationToken);

            ctx.LogMessage("Successfully authenticated client.");

            return(client);
        }
コード例 #60
0
 /*
  * Internal API, intended to be used by MonoTlsProvider implementations.
  */
 internal static ICertificateValidator2 GetInternalValidator(MonoTlsSettings settings, MonoTlsProvider provider)
 {
     return((ICertificateValidator2)NoReflectionHelper.GetInternalValidator(provider, settings));
 }