Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Selecting

    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?
    Wilfried Guest

  2. Similar Questions and Discussions

    1. selecting from two tables
      Hi I have one table called 'foobar_items' ID desc ________ ________________ foo1 very good foo foo2 ...
    2. SELECTING ROWS
      Hi again Im trying to select a particular ROW in my Database, I want to run a query on the 1st 2nd and 3rd rows seprately. the information will...
    3. SQL: Selecting everything BUT
      I have a table with 439 records in it. This table is linked to another, which is related to a 3rd via a 4th relationship table. I have a gigantic...
    4. selecting different css
      stu75 wrote: You could just attach a print media style sheet to accomplish this and won't need another page: Take a look at these articles:...
    5. selecting datagrid row
      Hello asp.net I've stuck a Select button from the property builder on my grid (Col 0). Upon click I'd like it to return the value in Col 1...
  3. #2

    Default RE: Selecting

    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.)

    [MSFT] Guest

  4. #3

    Default RE: Selecting

    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")



    "[MSFT]" wrote:
    > 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 Guest

  5. #4

    Default RE: Selecting

    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

    [MSFT] Guest

  6. #5

    Default RE: Selecting

    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

    "[MSFT]" wrote:
    > 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 Guest

  7. #6

    Default RE: Selecting

    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] Guest

  8. #7

    Default RE: Selecting

    Is there any further questions on this issue? If so, please feel free to
    post here.

    Regards,

    Luke

    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139