Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Security / October 2004

Tip: Looking for answers? Try searching our database.

Selecting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wilfried - 20 Oct 2004 11:51 GMT
I want to read the Elements of the Subject of a client certificate sent to a
Web Service via HTTPS. This can be done by the following code segment...

[WebMethod]
public string echoCert()
{
 string result = String.Empty;
 HttpClientCertificate cert = this.Context.Request.ClientCertificate;
 if (cert.IsPresent)
 {
   result = result + "Subject: " + cert.Subject + "\n";
   result = result + "SubjectCN: " + cert.Get("SUBJECTCN") + "\n";
   result = result + "SubjectOU: " + cert.Get("SUBJECTOU") + "\n";
   ...
   return result;
 }

My question: How can I read more than one OU= Element in the certificate?
[MSFT] - 21 Oct 2004 03:48 GMT
Hello,

The HttpClientCertificate is actually a NameValueConnection object. The
values in the collection can only be accessed by index. And it provide two
method to the get the values, Get() and GetValues(). I think you have to
read the Elements one by one as you have done in the code since
NameValueConnection didn't provide a method to read multiple values.

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Wilfried - 21 Oct 2004 11:55 GMT
Hello,

thank you for your reply. Unfortunately there seems to be a gap between
theory/documentation and praxis:

In my understanding the following code should read all values in the
Collection (which is made up by keyed string arrays):

HttpClientCertificate cert = this.Context.Request.ClientCertificate;
for (int k=0;k<cert.Count;k++)
{
 string[] sa = cert.GetValues(k);
 for (int i=0;i<sa.Length;i++)
 {
   result += sa[i];
 }
}

The line string[] sa = cert.GetValues(k) returned null, but the Get()-method
(as cert.Get("ISSUEROU") do work - and returned multiple OU-Elementes in one
string separated by semicolon (like ISSUEROU := "org1;org2")

> Hello,
>
[quoted text clipped - 8 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
[MSFT] - 22 Oct 2004 03:20 GMT
Hello,

To use Get() or GetValues, it depends on what had been saved in the
collection. If the item in the collection is string, Get() should be used;
if it is an string array, GetValues() should be used.  ISSUEROU is actually
a string, not a atring array, so that we can only use Get(0 to retrieve the
value. To seperate the string to an array like:

["org1","org2",...]

You may consider the String object's Split Method.

Hope this help,

Luke
Wilfried - 22 Oct 2004 10:03 GMT
Thank you very much.
Can you route me to some information about what is saved as string and what
is saved as array? Is it possible, that Certificate is a collection to which
all information is stored as (semicolon separated?) strings?

/wh

> Hello,
>
[quoted text clipped - 11 lines]
>
> Luke
[MSFT] - 25 Oct 2004 04:38 GMT
Thank you for the reply. Regarding the question, I think we can use
following code get a field's type:

cert["SUBJECTCN"].GetType()

This should be able to tel us the actual type of a field in the collection.

Luke
[MSFT] - 27 Oct 2004 07:27 GMT
Is there any further questions on this issue? If so, please feel free to
post here.

Regards,

Luke

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.