Skip to content

possible memleak in internal CertificateManager #59538

@leeriorio

Description

@leeriorio

In results of static analyze of aspnetcore sources with Svace static analyzer I was found error of cathegory HANDLE_LEAK with message

new X509Certificate2(certificatePath, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet) is not disposed at the end of the function

This error was found in internal method ImportCertificate

certificate = new X509Certificate2(certificatePath, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet);

I see, that there working with created certificate takes specific paths that include platform point, and in variable certificate it can be stored new certificate object.

But at all, how about to add correct disposing of object?
Maybe call of SaveCertificate method should be like:

using var _ = SaveCertifiicate(certificate);

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions