container name

N

nishu

hello,
how i can get the key container name for each certificate in the
my personal store
if i create the certificate using makecert.exe then i am able to
explicitly mention certificate key container name but if i have
certificate from the certififying authority how would i get the key
container name
please help me out
 
D

Dominick Baier [DevelopMentor]

hi,

this might help:

// user store is default store
StoreLocation location = StoreLocation.CurrentUser;

// open store
X509Store store = new X509Store(StoreName.My, location);
store.Open(OpenFlags.ReadOnly);

// select certificate
X509Certificate2Collection col = X509Certificate2UI.SelectFromCollection(
store.Certificates,
"www.leastprivilege.com",
"Select a Certificate",
X509SelectionFlag.SingleSelection);

store.Close();

if (col.Count != 1)
return;

// get path and filename of private key containers
string keyfileName = GetKeyFileName(col[0]);



private static string GetKeyFileName(X509Certificate2 cert)
{
string filename = null;

if (cert.PrivateKey != null)
{
RSACryptoServiceProvider provider = cert.PrivateKey as RSACryptoServiceProvider;
filename = provider.CspKeyContainerInfo.UniqueKeyContainerName;
}
return filename;
}
 
O

Olivi-Zhang

hi~ I build a CA based windows server 2003,and the aim of my project is to let users to request Certificate from this CA, and then users use their Certificate to sign the files that they want to send to others.The langusge i use is c#,and the project is based on b/s.
My problem is :if users ues the Certificate to fufill DigitalSignature,they must get the Privatekey of the Certificate,but the project is based on b/s,it seems the program can not access to the Client's Certificate-Store,Because when i use
//*********************************//
X509Store storeCertificates = new X509Store(StoreName.My, StoreLocation.CurrentUser);
int a =storeCertificates.count;
response.write(a);
//**********************************//
the result is a=0,but there are 3 Certificates in Certificate-store.And when i try these codes in Console,the result is correct(a=3),why? (Dose WebForm don't have purview to access the store of Certificate on the Client-PC?)

Please Help me~my email:eek:[email protected] ,thanks~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top