Mentalis.org Security Library documentation

Certificate.DecodeExtension Method (Extension, Int32, Type)

Decodes the specified extension and returns an object of the specified type that is instantiated with the decoded bytes.

[Visual Basic]
Overloads Public Shared Function DecodeExtension( _
   ByVal extension As Extension, _
   ByVal oid As Integer, _
   ByVal returnType As Type _
) As Object
[C#]
public static object DecodeExtension(
   Extension extension,
   int oid,
   Type returnType
);

Parameters

extension
The certificate extension to decode.
oid
One of the predefined constants specified in the Win32 CryptoAPI. Refer to the documentation of the CryptDecodeObject function for more information.
returnType
A Type instance. See remarks.

Return Value

An object of the type returnType.

Remarks

The specified type should have a public constructor that takes an IntPtr and an int as parameters [in that order]. The IntPtr is a pointer to the decoded buffer and the int contains the number of decoded bytes. The type should not keep the IntPtr reference after construction of an instance, because the memory is freed when the DecodeExtension method returns.

Exceptions

Exception TypeCondition
ArgumentNullExceptionOne of the parameters is a null reference (Nothing in Visual Basic).
CertificateExceptionAn error occurs while decoding the certificate extension.

See Also

Certificate Class | Org.Mentalis.Security.Certificates Namespace | Certificate.DecodeExtension Overload List