/// <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); } }
/// <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); } }
/// <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); } }
/// <summary> /// Calls SSL_CTX_new() /// </summary> /// <param name="sslMethod"></param> public SslContext(SslMethod sslMethod) : base(Native.ExpectNonNull(Native.SSL_CTX_new(sslMethod.Handle)), true) { }
/// <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); } }