private static unsafe uint QueryCertBlobType(byte[] rawData) { uint num = 0; if (!CAPI.CryptQueryObject(2, rawData, 0x3ffe, 14, 0, IntPtr.Zero, new IntPtr((void *)&num), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } return(num); }
private static unsafe uint QueryCertFileType(string fileName) { uint num = 0; if (!CAPI.CryptQueryObject(1, fileName, 0x3ffe, 14, 0, IntPtr.Zero, new IntPtr((void *)&num), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } return(num); }
private static unsafe System.Security.Cryptography.SafeCertStoreHandle LoadStoreFromFile(string fileName, string password, uint dwFlags, bool persistKeyContainers) { uint num = 0; System.Security.Cryptography.SafeCertStoreHandle invalidHandle = System.Security.Cryptography.SafeCertStoreHandle.InvalidHandle; if (!CAPI.CryptQueryObject(1, fileName, 0x1732, 14, 0, IntPtr.Zero, new IntPtr((void *)&num), IntPtr.Zero, ref invalidHandle, IntPtr.Zero, IntPtr.Zero)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } if (num == 12) { invalidHandle.Dispose(); invalidHandle = CAPI.PFXImportCertStore(1, fileName, password, dwFlags, persistKeyContainers); } if ((invalidHandle == null) || invalidHandle.IsInvalid) { throw new CryptographicException(Marshal.GetLastWin32Error()); } return(invalidHandle); }