Skip to content

Question: do I need to dispose the X509Certificate2 elements in an X509Chain myself? #112987

Closed
dotnet/dotnet-api-docs
#11042
@drauch

Description

@drauch

I've experienced that the following code works just fine:

var x509Chain = new X509Chain();
x509Chain.Build(someCert);

var certs = x509Chain.ChainElements.Select(ce => ce.Certificate).ToList();
x509Chain.Dispose();

// make use of certs, even calling methods like GetRSAPublicKey() does not throw

It looks like the X509Certificate2 objects inside a chain are not disposed with the chain. Is that so? Do I need to dispose them myself when I dispose the chain to do proper cleanup?

Best regards,
D.R.

Metadata

Metadata

Assignees

Labels

area-System.SecuritydocumentationDocumentation bug or enhancement, does not impact product or test code

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions