Exemplo n.º 1
0
		public 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)
		{
			TlsConfiguration config;
			if (serverMode) {
				var cert = (PSSCX.X509Certificate2)serverCertificate;
				var monoCert = new MX.X509Certificate (cert.RawData);
				config = new TlsConfiguration ((TlsProtocols)protocolFlags, (MSI.MonoTlsSettings)settings, monoCert, cert.PrivateKey);
				if (remoteCertRequired)
					config.AskForClientCertificate = true;
			} else {
				config = new TlsConfiguration ((TlsProtocols)protocolFlags, (MSI.MonoTlsSettings)settings, hostname);
			}

			return new TlsContextWrapper (config, serverMode);
		}
Exemplo n.º 2
0
		internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
			: base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
		{
		}
Exemplo n.º 3
0
		internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
			: this (innerStream, false, provider, settings)
		{
		}
Exemplo n.º 4
0
		public void Initialize (MSI.IMonoTlsEventSink eventSink)
		{
			if (context != null)
				throw new InvalidOperationException ();
			context = new TlsContext (config, serverMode, eventSink);
		}
Exemplo n.º 5
0
			public static BOSWrapper Wrap (MSI.IBufferOffsetSize bos)
			{
				return bos != null ? new BOSWrapper (bos.Buffer, bos.Offset, bos.Size) : null;
			}
Exemplo n.º 6
0
		public int DecryptMessage (ref MSI.IBufferOffsetSize incoming)
		{
			var buffer = new TlsBuffer (BOSWrapper.Wrap (incoming));
			var retval = Context.DecryptMessage (ref buffer);
			incoming = buffer != null ? BOSWrapper.Wrap (buffer.GetRemaining ()) : null;
			return (int)retval;
		}
Exemplo n.º 7
0
		public int GenerateNextToken (MSI.IBufferOffsetSize incoming, out MSI.IBufferOffsetSize outgoing)
		{
			var input = incoming != null ? new TlsBuffer (BOSWrapper.Wrap (incoming)) : null;
			TlsMultiBuffer output = new TlsMultiBuffer ();
			var retval = Context.GenerateNextToken (input, output);
			if (output.IsEmpty)
				outgoing = null;
			outgoing = BOSWrapper.Wrap (output.StealBuffer ());
			return (int)retval;
		}
Exemplo n.º 8
0
		public static bool IsNewTlsStream (MSI.MonoSslStream stream)
		{
			return stream is MonoSslStreamImpl;
		}
Exemplo n.º 9
0
		public override MSI.MonoSslStream CreateSslStream (
			Stream innerStream, bool leaveInnerStreamOpen,
			MSI.MonoTlsSettings settings = null)
		{
			return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
		}
Exemplo n.º 10
0
		public static MonoNewTlsStream GetNewTlsStream (MSI.MonoSslStream stream)
		{
			return ((MonoSslStreamImpl)stream).Impl;
		}