예제 #1
0
        public override void Close()
        {
            Debug("Close!");

            if (ssl != null)
            {
                ssl.Dispose();
                ssl = null;
            }
            if (ctx != null)
            {
                ctx.Dispose();
                ctx = null;
            }
            if (bio != null)
            {
                bio.Dispose();
                bio = null;
            }
            if (errbio != null)
            {
                errbio.Dispose();
                errbio = null;
            }
        }
예제 #2
0
        static BoringSslHandle Create_internal(MonoBtlsSslCtx ctx)
        {
            var handle = mono_btls_ssl_new(ctx.Handle.DangerousGetHandle());

            if (handle == IntPtr.Zero)
            {
                throw new MonoBtlsException();
            }
            return(new BoringSslHandle(handle));
        }
예제 #3
0
        void InitializeConnection()
        {
            ctx = new MonoBtlsSslCtx();

#if MARTIN_DEBUG
            errbio = MonoBtlsBio.CreateMonoStream(Console.OpenStandardError());
            ctx.SetDebugBio(errbio);
#endif

            MonoBtlsProvider.SetupCertificateStore(ctx.CertificateStore, Settings, IsServer);

            if (!IsServer || AskForClientCertificate)
            {
                ctx.SetVerifyCallback(VerifyCallback, false);
            }
            if (!IsServer)
            {
                ctx.SetSelectCallback(SelectCallback);
            }

            if (IsServer && (Options.ServerCertSelectionDelegate != null || Settings.ClientCertificateSelectionCallback != null))
            {
                ctx.SetServerNameCallback(ServerNameCallback);
            }

            ctx.SetVerifyParam(MonoBtlsProvider.GetVerifyParam(Settings, ServerName, IsServer));

            TlsProtocolCode?minProtocol, maxProtocol;
            GetProtocolVersions(out minProtocol, out maxProtocol);

            if (minProtocol != null)
            {
                ctx.SetMinVersion((int)minProtocol.Value);
            }
            if (maxProtocol != null)
            {
                ctx.SetMaxVersion((int)maxProtocol.Value);
            }

            if (Settings != null && Settings.EnabledCiphers != null)
            {
                var ciphers = new short [Settings.EnabledCiphers.Length];
                for (int i = 0; i < ciphers.Length; i++)
                {
                    ciphers [i] = (short)Settings.EnabledCiphers [i];
                }
                ctx.SetCiphers(ciphers, true);
            }

            if (IsServer && Settings?.ClientCertificateIssuers != null)
            {
                ctx.SetClientCertificateIssuers(Settings.ClientCertificateIssuers);
            }
        }
예제 #4
0
        void InitializeConnection()
        {
            ctx = new MonoBtlsSslCtx();

#if MARTIN_DEBUG
            errbio = MonoBtlsBio.CreateMonoStream(Console.OpenStandardError());
            ctx.SetDebugBio(errbio);
#endif

            SetupCertificateStore();

            if (!IsServer || AskForClientCertificate)
            {
                ctx.SetVerifyCallback(VerifyCallback, false);
            }
            if (!IsServer)
            {
                ctx.SetSelectCallback(SelectCallback);
            }

            var host = TargetHost;
            if (!string.IsNullOrEmpty(host))
            {
                var pos = TargetHost.IndexOf(':');
                if (pos > 0)
                {
                    host = host.Substring(0, pos);
                }
            }

            ctx.SetVerifyParam(MonoBtlsProvider.GetVerifyParam(host, IsServer));

            TlsProtocolCode minProtocol, maxProtocol;
            GetProtocolVersions(out minProtocol, out maxProtocol);

            ctx.SetMinVersion((int)minProtocol);
            ctx.SetMaxVersion((int)maxProtocol);

            if (Settings != null && Settings.EnabledCiphers != null)
            {
                var ciphers = new short [Settings.EnabledCiphers.Length];
                for (int i = 0; i < ciphers.Length; i++)
                {
                    ciphers [i] = (short)Settings.EnabledCiphers [i];
                }
                ctx.SetCiphers(ciphers, true);
            }
        }
예제 #5
0
		public MonoBtlsSsl (MonoBtlsSslCtx ctx)
			: base (Create_internal (ctx))
		{
			printErrorsFunc = PrintErrorsCallback;
			printErrorsFuncPtr = Marshal.GetFunctionPointerForDelegate (printErrorsFunc);
		}
예제 #6
0
		static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx)
		{
			var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ());
			if (handle == IntPtr.Zero)
				throw new MonoBtlsException ();
			return new BoringSslHandle (handle);
		}
예제 #7
0
 public MonoBtlsSsl(MonoBtlsSslCtx ctx)
     : base(Create_internal(ctx))
 {
     printErrorsFunc    = PrintErrorsCallback;
     printErrorsFuncPtr = Marshal.GetFunctionPointerForDelegate(printErrorsFunc);
 }
예제 #8
0
		internal MonoBtlsX509Store (MonoBtlsSslCtx.BoringSslCtxHandle ctx)
			: base (Create_internal (ctx))
		{
		}
예제 #9
0
		static BoringX509StoreHandle Create_internal (MonoBtlsSslCtx.BoringSslCtxHandle ctx)
		{
			var handle = mono_btls_x509_store_from_ssl_ctx (ctx.DangerousGetHandle ());
			if (handle == IntPtr.Zero)
				throw new MonoBtlsException ();
			return new BoringX509StoreHandle (handle);
		}