confluent-kafka-dotnet
confluent-kafka-dotnet copied to clipboard
CachedSchemaRegistryClient not Disposing X509Certificate2
Description
The CachedSchemaRegistryClient is creating certificates but not disposing them. This causes the temp files created at %APPDATA%\Roaming\Microsoft\Crypto\RSA to not be deleted.
Nuget version 2.3
How to reproduce
You'll need a pfx file. For this code the pfx file has no password.
using Confluent.SchemaRegistry;
var config = new SchemaRegistryConfig
{
Url = "https://anything.com",
SslKeystoreLocation = "[path to your pfx file]"
};
var x = new CachedSchemaRegistryClient(config);
x.Dispose();
Now check that file location and you'll see a guid file there. Each time you run it will add a new one. If you Dispose (or Reset) the certificate that file gets cleaned up.
Not sure of the best solution but one option would be in the RestClient to add the passed in certificates to a local variable. Then on Dispose for that client loop through the certificates and dispose them as well.
Checklist
Please provide the following information:
- [X] A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
- [X] Confluent.Kafka nuget version.
- [ ] Apache Kafka version.
- [ ] Client configuration.
- [ ] Operating system.
- [ ] Provide logs (with "debug" : "..." as necessary in configuration).
- [ ] Provide broker log excerpts.
- [ ] Critical issue.