public static extern IntPtr CertCreateSelfSignCertificate( [In, Optional] IntPtr phProv, [In] Wincrypt.CRYPTOAPI_BLOB pSubjectIssuerBlob, [In] UInt32 flags, [In, Optional] Wincrypt.CRYPT_KEY_PROV_INFO pKeyProvInfo, [In, Optional] IntPtr pSignatureAlgorithm, [In, Optional] Wincrypt.SystemTime pStartTime, [In, Optional] Wincrypt.SystemTime pEndTime, [Optional] Wincrypt.CERT_EXTENSIONS pExtensions );
void get_extensions() { if (CTLInfo.cExtension > 0) { Wincrypt.CERT_EXTENSIONS extstruct = new Wincrypt.CERT_EXTENSIONS { rgExtension = CTLInfo.rgExtension, cExtension = CTLInfo.cExtension }; _listExtensions.AddRange(CryptographyUtils.DecodeX509ExtensionCollection2(extstruct)); } }
static List <X509Extension> decode_extstruct(Wincrypt.CERT_EXTENSIONS extstruct) { List <X509Extension> extensions = new List <X509Extension>(); if (extstruct.cExtension > 0) { IntPtr rgExtension = extstruct.rgExtension; for (UInt32 index = 0; index < extstruct.cExtension; index++) { Wincrypt.CERT_EXTENSION ExtEntry = (Wincrypt.CERT_EXTENSION)Marshal.PtrToStructure(rgExtension, typeof(Wincrypt.CERT_EXTENSION)); Byte[] rawData = new Byte[ExtEntry.Value.cbData]; Marshal.Copy(ExtEntry.Value.pbData, rawData, 0, rawData.Length); extensions.Add(ConvertExtension(new X509Extension(ExtEntry.pszObjId, rawData, ExtEntry.fCritical))); rgExtension = rgExtension + Marshal.SizeOf(typeof(Wincrypt.CERT_EXTENSION)); } } return(extensions); }
internal static IEnumerable <X509Extension> DecodeX509ExtensionCollection2(Wincrypt.CERT_EXTENSIONS extstruct) { return(decode_extstruct(extstruct).ToArray()); }