/// <summary> /// Does not throw on api error. Returns default(bool?) and sets "exception" instead. /// </summary> public bool? Verify(X509VerificationFlags flags, out Exception exception) { exception = null; CERT_CHAIN_POLICY_PARA para = new CERT_CHAIN_POLICY_PARA() { cbSize = Marshal.SizeOf<CERT_CHAIN_POLICY_PARA>(), dwFlags = (int)flags, }; CERT_CHAIN_POLICY_STATUS status = new CERT_CHAIN_POLICY_STATUS() { cbSize = Marshal.SizeOf<CERT_CHAIN_POLICY_STATUS>(), }; if (!Interop.crypt32.CertVerifyCertificateChainPolicy(ChainPolicy.CERT_CHAIN_POLICY_BASE, _chain, ref para, ref status)) { int errorCode = Marshal.GetLastWin32Error(); exception = errorCode.ToCryptographicException(); return default(bool?); } return status.dwError == 0; }
public static bool CertVerifyCertificateChainPolicy(ChainPolicy pszPolicyOID, SafeX509ChainHandle pChainContext, ref CERT_CHAIN_POLICY_PARA pPolicyPara, ref CERT_CHAIN_POLICY_STATUS pPolicyStatus) { return CertVerifyCertificateChainPolicy((IntPtr)pszPolicyOID, pChainContext, ref pPolicyPara, ref pPolicyStatus); }
private static extern bool CertVerifyCertificateChainPolicy(IntPtr pszPolicyOID, SafeX509ChainHandle pChainContext, [In] ref CERT_CHAIN_POLICY_PARA pPolicyPara, [In, Out] ref CERT_CHAIN_POLICY_STATUS pPolicyStatus);
public static bool CertVerifyCertificateChainPolicy(ChainPolicy pszPolicyOID, SafeX509ChainHandle pChainContext, ref CERT_CHAIN_POLICY_PARA pPolicyPara, ref CERT_CHAIN_POLICY_STATUS pPolicyStatus) { return(CertVerifyCertificateChainPolicy((IntPtr)pszPolicyOID, pChainContext, ref pPolicyPara, ref pPolicyStatus)); }