示例#1
0
		public TlsContext (TlsConfiguration configuration, bool isServer)
		{
			this.configuration = configuration;
			this.isServer = isServer;

			#if INSTRUMENTATION
			if (configuration.HasInstrumentation) {
				if (configuration.Instrumentation.HasSignatureInstrument)
					signatureProvider = configuration.Instrumentation.SignatureInstrument;
				if (configuration.Instrumentation.HasSettingsInstrument)
					settingsProvider = configuration.Instrumentation.SettingsInstrument;
				handshakeInstruments = configuration.Instrumentation.HandshakeInstruments;
			}
			#endif

			if (signatureProvider == null)
				signatureProvider = new SignatureProvider ();
			if (settingsProvider == null)
				settingsProvider = new SettingsProvider (configuration.TlsSettings.UserSettings);

			session = new Session (configuration);
			Session.RandomNumberGenerator = RandomNumberGenerator.Create ();

			if (IsServer)
				negotiationHandler = CreateNegotiationHandler (NegotiationState.InitialServerConnection);
			else
				negotiationHandler = CreateNegotiationHandler (NegotiationState.InitialClientConnection);

			if (settingsProvider.EnableDebugging ?? false)
				EnableDebugging = true;

			settingsProvider.Initialize (this);
		}
示例#2
0
        public TlsContext(TlsConfiguration configuration, bool isServer, IMonoTlsEventSink eventSink)
        {
            this.configuration = configuration;
            this.isServer      = isServer;
            this.eventSink     = eventSink;

                        #if INSTRUMENTATION
            var instrumentation = configuration.UserSettings.Instrumentation;
            if (instrumentation != null)
            {
                if (instrumentation.HasSignatureInstrument)
                {
                    signatureProvider = instrumentation.SignatureInstrument;
                }
                if (instrumentation.HasSettingsInstrument)
                {
                    settingsProvider = instrumentation.SettingsInstrument;
                }
                handshakeInstruments     = instrumentation.HandshakeInstruments;
                instrumentationEventSink = instrumentation.EventSink;
            }
                        #endif

            if (signatureProvider == null)
            {
                signatureProvider = new SignatureProvider();
            }
            if (settingsProvider == null)
            {
                settingsProvider = new SettingsProvider(configuration.UserSettings);
            }

            session = new Session(configuration);
            Session.RandomNumberGenerator = RandomNumberGenerator.Create();

            if (IsServer)
            {
                negotiationHandler = CreateNegotiationHandler(NegotiationState.InitialServerConnection);
            }
            else
            {
                negotiationHandler = CreateNegotiationHandler(NegotiationState.InitialClientConnection);
            }

            if (settingsProvider.EnableDebugging)
            {
                EnableDebugging = true;
            }

            settingsProvider.Initialize(this);
        }