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

GetPrivateKeyFilePath() public method

public GetPrivateKeyFilePath ( string thumbprint ) : string
thumbprint string
return string
        public string GetPrivateKeyFilePath(string thumbprint)
        {
            lock (m_lock)
            {
                IntPtr hStore = IntPtr.Zero;

                try
                {
                    // open store.
                    hStore = OpenStore(true, false, true);

                    // get the container information.
                    CspKeyContainerInfo container = GetCspKeyContainerInfo(hStore, thumbprint, m_symbolicName, m_storeType);

                    if (container == null)
                    {
                        return null;
                    }

                    // get the key file.
                    FileInfo keyFile = GetKeyFileInfo(
                        container.UniqueKeyContainerName,
                        m_storeType,
                        m_serviceNameOrUserSid);

                    // return the full path.
                    return keyFile.FullName;
                }
                finally
                {
                    if (hStore != IntPtr.Zero)
                    {
                        NativeMethods.CertCloseStore(hStore, 0);
                    }
                }
            }
        }