Originally Posted by palaniappan1
|
|
I dont think a proper doc is there. I'll try to add that. Anyway, the source code is available at developer.novell.com (under the 'Ldap Libraries for Csharp').
|
All of the HEX codes provided are positive values. Yet all of the integers I've seen passed into the UserDefinedServerCertValidationDelegate are negative. I believe this is because of an overflow when casting an uint (or long?) to an int.
This means that any developers that implement their own handlers have to depend on an cast overflow, which is less than ideal. Perhaps the signature of the delegate should contain uint[] or long[] instead. This test shows the problem. I created my own CertificateError enum that extends uint and uses the HEX values provided.
|
Code:
|
[Test]
public void TestCertErr()
{
var errors = (CertificateError[]) Enum.GetValues(typeof(CertificateError));
foreach (var error in errors)
{
uint certificateError = (uint) error;
bool isTooBig = certificateError > int.MaxValue;
if (isTooBig)
{
Log.WarnFormat(null, "Overflow: 0x{0:X2} {1,-25} => \t{2}",
certificateError, Enum.GetName(typeof (CertificateError), certificateError),
(int) certificateError);
}
// cast may overflow
int intErr = (int)certificateError;
Assert.IsTrue(!isTooBig || intErr < 0);
uint roundTrip = (uint)intErr;
Assert.AreEqual(certificateError, roundTrip);
}
}
|
Which produces the following output:
|
Code:
|
Overflow: 0x800B0102 ValidityPeriodNesting => -2146762494
Overflow: 0x800B0103 Role => -2146762493
Overflow: 0x800B0104 PathLenConst => -2146762492
Overflow: 0x800B0105 Critical => -2146762491
Overflow: 0x800B0106 Purpose => -2146762490
Overflow: 0x800B0107 IssuerChaining => -2146762489
Overflow: 0x800B0108 Malformed => -2146762488
Overflow: 0x800B0109 UntrustedRoot => -2146762487
Overflow: 0x800B010A Chaining => -2146762486
Overflow: 0x800B010C Revoked => -2146762484
Overflow: 0x800B010D UntrustedTestRoot => -2146762483
Overflow: 0x800B010E RevocationFailure => -2146762482
Overflow: 0x800B010F CnNoMatch => -2146762481
Overflow: 0x800B0110 WrongUsage => -2146762480
Overflow: 0x800B0112 UntrustedCA => -2146762478
Overflow: 0x800B0113 UnrecognizedError => -2146762477 |