by Gareth [sluglit at hotmail dot com] posted on 2004/03/15 |
|
I have found a bug in the Certificate object.
After deleting a certificate from a Certificate store an exception is thrown in the finalize method of the certificate object
Here's what I'm doing :
1. Create a certificate request with exportable private keys.
2. Then open the Request certificate store.
3. Get the certificate request from the request store.
4. Save the certificate to disk .
5. Delete the certificte from the request store.
6. Program ends and garbage collection cleans up everything.
7. Exception is thrown from the Certificates finalize object...
Below is example code :
CertificateStore store = new CertificateStore("REQUEST");
Certificate c = store.FindCertificateBySubjectName(myDN);
if(c != null)
{
System.Console.WriteLine("Retrieved request : " + c.GetName());
FileInfo file = new FileInfo("c:\\cert1.pfx");
if(file.Exists) file.Delete();
System.Console.WriteLine("Saving request : " + file.FullName);
c.ToPfxFile(file.FullName, "password", true, true);
System.Console.WriteLine("Deleting request : " + file.FullName);
store.DeleteCertificate(c);
}
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Org.Mentalis.Security.SspiProvider.CertFreeCertificateContext(IntPtr pCert
Context)
at Org.Mentalis.Security.Certificates.Certificate.Finalize() |