private static unsafe void RemoveSessionCallback(IntPtr ctx, IntPtr session) { Debug.Assert(ctx != IntPtr.Zero && session != IntPtr.Zero); IntPtr ptr = Ssl.SslCtxGetData(ctx); if (ptr == IntPtr.Zero) { // Same as above, SafeSslContextHandle could be released while OpenSSL still holds reference. return; } GCHandle gch = GCHandle.FromIntPtr(ptr); SafeSslContextHandle?ctxHandle = gch.Target as SafeSslContextHandle; if (ctxHandle == null) { return; } IntPtr name = Ssl.SessionGetHostname(session); Debug.Assert(name != IntPtr.Zero); ctxHandle.RemoveSession(name, session); }