RE: Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString
From: Peter Huang (v-phuang_at_online.microsoft.com)
Date: 02/23/05
- Next message: Morten Wennevik: "Re: Cant install dotnet framework on my pc"
- Previous message: Anoop: "Doubt regarding Trace Event in EIF"
- In reply to: John Allberg: "Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Next in thread: John Allberg: "Re: Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Reply: John Allberg: "Re: Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 09:31:27 GMT
Hi
Based on my research, I think this is the different order about how win32
explorer and .NET framework handle the serial number byte array.
I have tried to open a test certificate and I find that the certificate's
byte array order is same as the output of .net's GetSerialNumber method. It
seems that the explorer has done the reverse job in advance. Based on my
knowlege, the serial number is used to identify the certificate which is
similar with GUID, so usually we use it to compare if two cert is identity.
So in the .net world, we do not need to do the reverse job.
While if you want to show the serialnumber same with the explorer.
We can just do the reserver job in .net as below.
// The path to the certificate.
string Certificate = @"c:\test.cer";
// Load the certificate into an X509Certificate object.
X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);
// Get the value.
byte[] results = cert.GetSerialNumber();
Array.Reverse(results);
// Display the value to the console.
foreach(byte b in results)
{
Console.Write("{0:x} ",b);
}
Console.WriteLine();
If you still have any concern, please feel free to post here.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
- Next message: Morten Wennevik: "Re: Cant install dotnet framework on my pc"
- Previous message: Anoop: "Doubt regarding Trace Event in EIF"
- In reply to: John Allberg: "Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Next in thread: John Allberg: "Re: Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Reply: John Allberg: "Re: Bug in X509Certificate.GetSerialNumber and X509Certificate.GetSerialNumberString"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|