Wraps the SSL_METHOD structure and methods
Inheritance: OpenSSL.Core.Base
Exemplo n.º 1
0
		/// <summary>
		///     Calls SSL_CTX_new()
		/// </summary>
		/// <param name="sslMethod"></param>
		/// <param name="end"></param>
		/// <param name="protoList"></param>
		public SslContext(
			SslMethod sslMethod,
			ConnectionEnd end,
			IEnumerable<string> protoList) :
			base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
		{
			alpnExt = new AlpnExtension(Handle, protoList);

			_ptrOnClientCertThunk = OnClientCertThunk;
			_ptrOnVerifyCertThunk = OnVerifyCertThunk;
			_ptrOnAlpn = alpnExt.AlpnCb;

			if (end == ConnectionEnd.Server)
			{
				Native.SSL_CTX_set_alpn_select_cb(Handle, _ptrOnAlpn, IntPtr.Zero);
			}
		}
Exemplo n.º 2
0
        /// <summary>
        ///     Calls SSL_CTX_new()
        /// </summary>
        /// <param name="sslMethod"></param>
        /// <param name="end"></param>
        /// <param name="protoList"></param>
        public SslContext(
            SslMethod sslMethod,
            ConnectionEnd end,
            IEnumerable <string> protoList) :
            base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
        {
            alpnExt = new AlpnExtension(Handle, protoList);

            _ptrOnClientCertThunk = OnClientCertThunk;
            _ptrOnVerifyCertThunk = OnVerifyCertThunk;
            _ptrOnAlpn            = alpnExt.AlpnCb;

            if (end == ConnectionEnd.Server)
            {
                Native.SSL_CTX_set_alpn_select_cb(Handle, _ptrOnAlpn, IntPtr.Zero);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Calls SSL_CTX_new()
        /// </summary>
        /// <param name="sslMethod"></param>
        /// <param name="end"></param>
        /// <param name="includeAlpn"></param>
        /// <param name="protoList"></param>
        public SslContext(SslMethod sslMethod, ConnectionEnd end, bool includeAlpn, IEnumerable <string> protoList = null)
            :
            base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
        {
            if (!includeAlpn)
            {
                return;
            }

            alpnExt = new AlpnExtension(Handle, protoList);

            if (end == ConnectionEnd.Server)
            {
                alpnCb = alpnExt.AlpnCb;
                var alpnCbPtr = Marshal.GetFunctionPointerForDelegate(alpnCb);
                var arg       = new IntPtr();
                Native.SSL_CTX_set_alpn_select_cb(Handle, alpnCbPtr, arg);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Calls SSL_CTX_new()
 /// </summary>
 /// <param name="sslMethod"></param>
 public SslContext(SslMethod sslMethod) :
     base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Calls SSL_CTX_new()
 /// </summary>
 /// <param name="sslMethod"></param>
 public SslContext(SslMethod sslMethod)
     : base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
 {
 }
Exemplo n.º 6
0
        /// <summary>
        ///     Calls SSL_CTX_new()
        /// </summary>
        /// <param name="sslMethod"></param>
        /// <param name="end"></param>
        /// <param name="includeAlpn"></param>
        /// <param name="protoList"></param>
        public SslContext(SslMethod sslMethod, ConnectionEnd end, bool includeAlpn, IEnumerable<string> protoList = null)
            : base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true)
        {
            if (!includeAlpn)
                return;

            alpnExt = new AlpnExtension(Handle, protoList);

            if (end == ConnectionEnd.Server)
            {
                alpnCb = alpnExt.AlpnCb;
                var alpnCbPtr = Marshal.GetFunctionPointerForDelegate(alpnCb);
                var arg = new IntPtr();
                AlpnExtension.SSL_CTX_set_alpn_select_cb(Handle, alpnCbPtr, arg);
            }
        }