mscorlib(4.0.0.0) API with additions
X509ChainElement.cs
2 
4 {
6  public class X509ChainElement
7  {
8  private X509Certificate2 m_certificate;
9 
10  private X509ChainStatus[] m_chainStatus;
11 
12  private string m_description;
13 
16  public X509Certificate2 Certificate => m_certificate;
17 
20  public X509ChainStatus[] ChainElementStatus => m_chainStatus;
21 
24  public string Information => m_description;
25 
26  private X509ChainElement()
27  {
28  }
29 
30  internal unsafe X509ChainElement(IntPtr pChainElement)
31  {
32  CAPIBase.CERT_CHAIN_ELEMENT cERT_CHAIN_ELEMENT = new CAPIBase.CERT_CHAIN_ELEMENT(Marshal.SizeOf(typeof(CAPIBase.CERT_CHAIN_ELEMENT)));
33  uint num = (uint)Marshal.ReadInt32(pChainElement);
34  if (num > Marshal.SizeOf((object)cERT_CHAIN_ELEMENT))
35  {
36  num = (uint)Marshal.SizeOf((object)cERT_CHAIN_ELEMENT);
37  }
38  System.Security.Cryptography.X509Certificates.X509Utils.memcpy(pChainElement, new IntPtr(&cERT_CHAIN_ELEMENT), num);
39  m_certificate = new X509Certificate2(cERT_CHAIN_ELEMENT.pCertContext);
40  if (cERT_CHAIN_ELEMENT.pwszExtendedErrorInfo == IntPtr.Zero)
41  {
42  m_description = string.Empty;
43  }
44  else
45  {
46  m_description = Marshal.PtrToStringUni(cERT_CHAIN_ELEMENT.pwszExtendedErrorInfo);
47  }
48  if (cERT_CHAIN_ELEMENT.dwErrorStatus == 0)
49  {
50  m_chainStatus = new X509ChainStatus[0];
51  }
52  else
53  {
54  m_chainStatus = X509Chain.GetChainStatusInformation(cERT_CHAIN_ELEMENT.dwErrorStatus);
55  }
56  }
57  }
58 }
static int ReadInt32([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a 32-bit signed integer at a given offset from unmanaged memory.
Provides a simple structure for storing X509 chain status and error information.
X509ChainStatus [] ChainElementStatus
Gets the error status of the current X.509 certificate in a chain.
Definition: __Canon.cs:3
static int SizeOf(object structure)
Returns the unmanaged size of an object in bytes.
Definition: Marshal.cs:159
X509Certificate2 Certificate
Gets the X.509 certificate at a particular chain element.
string Information
Gets additional error information from an unmanaged certificate chain structure.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Definition: Marshal.cs:15
static unsafe string PtrToStringUni(IntPtr ptr, int len)
Allocates a managed T:System.String and copies a specified number of characters from an unmanaged Uni...
Definition: Marshal.cs:103
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20