예제 #1
0
		public TlsContext (TlsConfiguration configuration, bool isServer, IMonoTlsEventSink eventSink)
		{
			this.configuration = configuration;
			this.isServer = isServer;
			this.eventSink = eventSink;

			#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 (Configuration.TlsSettings != null && Configuration.TlsSettings.EnableDebugging)
				EnableDebugging = true;
			else if (settingsProvider.EnableDebugging ?? false)
				EnableDebugging = true;

			settingsProvider.Initialize (this);
		}
예제 #2
0
		public void Clear ()
		{
			negotiationHandler = null;
			if (handshakeParameters != null) {
				handshakeParameters.Dispose ();
				handshakeParameters = null;
			}
			if (session != null) {
				session.Dispose ();
				session = null;
			}
		}