Skip to content

SslStream RemoteCertificate disposal #5993

@bbowyersmyth

Description

@bbowyersmyth

The issue

Once the certificate has been accessed on an SslStream it will no longer dispose it when the stream is disposed. A bit of a hidden requirement is that the caller takes that responsibility once it is no longer needed.
https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslstream.remotecertificate?view=net-9.0#remarks

https://github.com/npgsql/npgsql/blob/main/src/Npgsql/Internal/NpgsqlConnector.Auth.cs#L193

Not sure if this causes any actual issues. Just noticed it in the code.

It also likely (always?) returns a X509Certificate2 instance so there may be no need to create a new one on line 199.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions