Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid allocation of SafeFreeSslCredentials and SafeDeleteSslContext on Linux #69527

Merged
merged 22 commits into from
Aug 15, 2022
Merged
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
Prev Previous commit
Next Next commit
feedback from review
  • Loading branch information
wfurt committed Aug 14, 2022
commit c81d78c6c7f55bc557e9a8300707ac07598618e0
Original file line number Diff line number Diff line change
@@ -46,9 +46,13 @@ public SafeDeleteNegoContext(SafeFreeNegoCredentials credential)
: base(IntPtr.Zero)
{
Debug.Assert((null != credential), "Null credential in SafeDeleteNegoContext");
bool added = false;
credential.DangerousAddRef(ref added);
if (!added)
{
throw new ObjectDisposedException(nameof(SafeFreeNegoCredentials));
}
wfurt marked this conversation as resolved.
Show resolved Hide resolved
_credential = credential;
wfurt marked this conversation as resolved.
Show resolved Hide resolved
bool ignore = false;
_credential.DangerousAddRef(ref ignore);
_context = new SafeGssContextHandle();
}

@@ -102,14 +106,14 @@ protected override void Dispose(bool disposing)
_acceptorCredential.Dispose();
_acceptorCredential = null;
}

if (_credential != null)
{
_credential.DangerousRelease();
_credential = null;
}
}
base.Dispose(disposing);
}

protected override bool ReleaseHandle()
{
_credential?.DangerousRelease();
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ private SslStreamCertificateContext(X509Certificate2 target, X509Certificate2[]
}
}

if (KeyHandle== null)
if (KeyHandle == null)
{
using (ECDsaOpenSsl? ecdsa = (ECDsaOpenSsl?)target.GetECDsaPrivateKey())
{
@@ -54,11 +54,11 @@ private SslStreamCertificateContext(X509Certificate2 target, X509Certificate2[]
KeyHandle = ecdsa.DuplicateKeyHandle();
}
}
}

if (KeyHandle== null)
{
throw new NotSupportedException(SR.net_ssl_io_no_server_cert);
if (KeyHandle== null)
{
throw new NotSupportedException(SR.net_ssl_io_no_server_cert);
}
}

CertificateHandle = Interop.Crypto.X509UpRef(target.Handle);
@@ -67,12 +67,6 @@ private SslStreamCertificateContext(X509Certificate2 target, X509Certificate2[]
internal static SslStreamCertificateContext Create(X509Certificate2 target) =>
Create(target, null, offline: false, trust: null, noOcspFetch: true);

~SslStreamCertificateContext()
{
CertificateHandle?.Dispose();
KeyHandle?.Dispose();
}

internal bool OcspStaplingAvailable => _ocspUrls is not null;

partial void SetNoOcspFetch(bool noOcspFetch)