Ephenodrom / Dart-Basic-Utils

A dart package for many helper methods fitting common situations
MIT License
364 stars 77 forks source link

Organizational Unit number is wrong #16

Closed certaintls closed 4 years ago

certaintls commented 4 years ago

This line https://github.com/Ephenodrom/Dart-Basic-Utils/blob/master/lib/src/X509Utils.dart#L50 defines it as 2.5.6.5, but when you print data.toJson().toString(), the OU is 2.5.4.11, which is confirmed by a simple search https://books.google.com/books?id=kEXIBAAAQBAJ&pg=PA25&lpg=PA25&dq=2.5.4.11+organizational+unit++certificate&source=bl&ots=YRgJH0Vgp0&sig=ACfU3U10ooyCzrVNQ5GSmSqrxWfe6jqlBA&hl=en&sa=X&ved=2ahUKEwiK4LfD9qbqAhUi-2EKHXTsBWYQ6AEwA3oECAsQAQ#v=onepage&q=2.5.4.11%20organizational%20unit%20%20certificate&f=false

Ephenodrom commented 4 years ago

Hello @certaintls and thanks for the issue.

The number 2.5.6.5 refers to the organizationUnit Class as described here https://oidref.com/2.5.6.5. What you mean is the organizationalUnitName that has the ObjectIdentifierNumber 2.5.4.11.

In an CSR or certificate the distinguished names ( DN ) offen contain the short version like "ou" that has the number 2.5.4.11. Thats why you receive this number instead of 2.5.6.5.

I will also add the full version for some distinguished names within the map.

certaintls commented 4 years ago

I see. Thanks for the information. Maybe I was using it wrong;

To access ou, we need to do data.subject['2.5.4.11'], but for seasonal developers who can't remember these numbers, I was trying to access it like data.subject[X509Utils.DN['organizationalUnit']], but this doesn't work.

Do you have a suggestion on how to access each field by using a human readable name?

Ephenodrom commented 4 years ago

Try this :

data.subject[X509Utils.DN['ou']];

As you can see on https://github.com/Ephenodrom/Dart-Basic-Utils/blob/master/lib/src/X509Utils.dart#L35.

certaintls commented 4 years ago

I see it now. Thanks. Shall I close this issue or you are still interested in making some improvement?

Ephenodrom commented 4 years ago

Let's keep this open, i will make some improvements to the DN map.

Ephenodrom commented 4 years ago

I updated the DN list and added the following data :

    'organizationalUnitName': '2.5.4.11',
    'organizationName': '2.5.4.10',
    'stateOrProvinceName': '2.5.4.8',
    'commonName': '2.5.4.3',
    'surname': '2.5.4.4',
    'countryName': '2.5.4.6',
    'localityName': '2.5.4.7',
    'streetAddress': '2.5.4.9'