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
 
Sample for CERT_ALT_NAME_ENTRY not working  
by Evan Montgomery-Recht [recht_evan at bah dot com]
posted on 2004/06/12

Tried using the following code to return the rfc822 name, which didn't seem to work.

I added to CERT_AUTHORITY_INFO_ACCESS.cs the

case CERT_ALT_NAME_RFC822_NAME:
this.unionObject = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(buffer, offset + 4));
break;

thinking that might work. but the problem that I ran into was that
this.dwAltNameChoice = Marshal.ReadInt32(buffer,offset);

was returning a number way to night 851931 or something like that. I expected the code in the CertificateExtensions.cs to be as follows

ext = cert.FindExtension("2.5.29.17");
if (ext != null) { // FindExtension returns a null pointer if the extension could not be found
CERT_ALT_NAME_ENTRY subalt = (CERT_ALT_NAME_ENTRY)Certificate.DecodeExtension(ext, ext.ObjectID, typeof(CERT_ALT_NAME_ENTRY));
Console.WriteLine(subalt.ToString());
}
so instead the hack that I got to work fine is the following...

ext = cert.FindExtension("2.5.29.17");
if (ext != null) {
Encoding ascii = Encoding.ASCII;
char[] asciiChars = new char[ext.EncodedValue.Length-4];
asciiChars = ascii.GetChars(ext.EncodedValue, 4,ext.EncodedValue.Length-4);
string asciiString = new string(asciiChars);
Console.WriteLine(asciiString);

}

any idea's why the sample code isn't working?

Please contact me via email.

thanks,

evan

by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2004/06/14

Unfortunately I don't hava a certificate that has a CERT_ALT_NAME_RFC822_NAME. If you could send me one, I'd be happy to test the code.

 

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