Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fold reference to SslContextHandle to prevent crashes
  • Loading branch information
wfurt committed Aug 15, 2022
commit 22c7e063b0a49007bc51846f478688809404cc7a
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ internal static SafeSslHandle AllocateSslHandle(SafeFreeSslCredentials credentia
if (cacheSslContext && !string.IsNullOrEmpty(punyCode))
{
sslCtxHandle.TrySetSession(sslHandle, punyCode);
bool ignored = false; // DangerousAddRef will throw on failure
sslCtxHandle.DangerousAddRef(ref ignored);
sslHandle.SslContextHandle = sslCtxHandle;
}

// relevant to TLS 1.3 only: if user supplied a client cert or cert callback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ internal sealed class SafeSslHandle : SafeHandle
private bool _handshakeCompleted;

public GCHandle AlpnHandle;
public SafeSslContextHandle? SslContextHandle;

public bool IsServer
{
Expand Down Expand Up @@ -432,6 +433,8 @@ protected override bool ReleaseHandle()
Disconnect();
}

SslContextHandle?.DangerousRelease();

IntPtr h = handle;
SetHandle(IntPtr.Zero);
Interop.Ssl.SslDestroy(h); // will free the handles underlying _readBio and _writeBio
Expand Down