EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Unable to Delete certificate from system store

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#8164
Posted: 11/11/2008 15:22:23
by bdog (Basic support level)
Joined: 11/11/2008
Posts: 2

I am attempting to add and delete a certificate from the system store and I am receiving an exception when attempting to delete "Unable to delete certificate".

We are using SecureBlackBox for .NET 6.0.0.144

Code to add certificate to the system store:-
using (TElWinCertStorage storage = new TElWinCertStorage())
{
storage.Clear();
storage.SystemStores.Add("SYSTEM");

storage.AccessType = TSBStorageAccessType.atLocalMachine;
storage.StorageType = TSBStorageType.stSystem;

storage.SystemStores.BeginUpdate();
storage.Add(cert, "SYSTEM", true, true, true);
storage.SystemStores.EndUpdate();
}



Code to remove the certificate from storage:-
using (TElWinCertStorage storage = new TElWinCertStorage())
{
storage.Clear();
storage.SystemStores.Add("SYSTEM");


TElX509Certificate cert = null;

int index = -1;

for (int i = 0; i < storage.Count; i++)
{
cert = storage.get_Certificates(i);
if (cert.SubjectName.CommonName == commonName)
{
index = i;
break;
}
}

if (index > -1)
{
storage.SystemStores.BeginUpdate();
storage.Remove(index); // Line that causes the exception
storage.SystemStores.EndUpdate();
}


}


#8168
Posted: 11/11/2008 23:43:47
by Ken Ivanov (EldoS Corp.)

You are not setting AccessType and StorageType properties in your certificate removal procedure. These properties are critical to work, please set them up and try to remove the certificate again.

BTW, there's no need in enveloping the Remove() call with SystemStores.BeginUpdate() and SystemStores.EndUpdate().
#8175
Posted: 11/12/2008 15:39:29
by bdog (Basic support level)
Joined: 11/11/2008
Posts: 2

thanks, that worked.

Reply

Statistics

Topic viewed 1256 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!