Opc.Ua.WindowsCertificateStore.FindCertificate C# (CSharp) Method

FindCertificate() private static method

Finds a certificate in the store.
private static FindCertificate ( IntPtr hStore, string thumbprint ) : IntPtr
hStore System.IntPtr The handle for the store to search.
thumbprint string The thumbprint of the certificate to find.
return System.IntPtr
        private static IntPtr FindCertificate(IntPtr hStore, string thumbprint)
        {
            IntPtr pCertContext = NativeMethods.CertEnumCertificatesInStore(hStore, IntPtr.Zero);

            while (pCertContext != IntPtr.Zero)
            {
                string targetThumbprint = GetThumbprint(pCertContext);

                if (targetThumbprint == thumbprint)
                {
                    break;
                }

                pCertContext = NativeMethods.CertEnumCertificatesInStore(hStore, pCertContext);
            }

            return pCertContext;
        }