News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
how to find a known client certificate's root certificate in rootStore?  
by lembas [lembas at myway dot com]
posted on 2003/09/14

how to find a known client certificate's root certificate in rootStore?

**********************
string issuertofcert = cert.GetIssuerName();
Certificate root = castore.FindCertificateBySubjectString(issuertofcert);
********************

the above does not work because there can be two root certificates having the same subject string. I want to get the
right root certificate.

actually, verifyChain(cert) method must find the root certificate somewhere inside the code. how can i get it?

Also, can i get the x500 string of my root certificate's subject from my client certificate and use it in FindCertificateBySubjectName(rootcert)? (by the way, is there a possibility that two root certificates having the same subject name? if so, this way does not work either.)

or;

is there any other way?

I would appreciate it so much if anyone replies fast.
Thanks in advance

by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2003/09/15

You can use the following code to get the root certificate [if it can be found]:

CertificateChain cc = new CertificateChain(mycert);
Certificate[] certs = cc.GetCertificates();

The last certificate in the array (certs[certs.Length-1]) is the root certificate -- if it can be found.

by lembas [lembas at myway dot com]
posted on 2003/09/16

I tried it but it did not work. The thing is I can verify the certificate which means the root should be found when cc.GetCertificates() in your suggestion code. But the array's length is always 1 and the only certificate in it is my client certificate.

by lembas [lembas at myway dot com]
posted on 2003/09/16

"verify" in my previous post means "chain verify". cc.VerifyChain(...)
gives me CertificateStatus.ValidCertificate. It can find the root in my CertificateStore.RootStore. But cc.GetCertificates() can not. why?

by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2003/09/16

Have you tried sepcifying the ROOT store as the additional store when creating instantiating the CertificateChain instance?

root = new CertificateStore(CertificateStore.RootStore);
cc = new CertificateChain(mycert, root);

by lembas [lembas at myway dot com]
posted on 2003/09/17

does not work. same result. array with 1 cert in it. i coded the certificate parser myself. many thanks anyway. just keep developing the libraries. (suggestion: i could not find a free asn1 parser for c#)

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.