예제 #1
0
        /// <summary>
        /// Find a certiifcate from string values
        /// </summary>
        /// <returns>The certificate.</returns>
        /// <param name="findType">Find type.</param>
        /// <param name="storeLocation">Store location.</param>
        /// <param name="storeName">Store name.</param>
        /// <param name="findValue">Find value.</param>
        public static X509Certificate2 FindCertificate(
            String findType,
            String storeLocation,
            String storeName,
            String findValue)
        {
            X509FindType  eFindType      = X509FindType.FindByThumbprint;
            StoreLocation eStoreLocation = StoreLocation.CurrentUser;
            StoreName     eStoreName     = StoreName.My;

            if (!Enum.TryParse(findType, out eFindType))
            {
                s_tracer.TraceWarning("{0} not valid value for {1}, using {2} as default", findType, eFindType.GetType().Name, eFindType);
            }

            if (!Enum.TryParse(storeLocation, out eStoreLocation))
            {
                s_tracer.TraceWarning("{0} not valid value for {1}, using {2} as default", storeLocation, eStoreLocation.GetType().Name, eStoreLocation);
            }

            if (!Enum.TryParse(storeName, out eStoreName))
            {
                s_tracer.TraceWarning("{0} not valid value for {1}, using {2} as default", storeName, eStoreName.GetType().Name, eStoreName);
            }

            return(FindCertificate(eFindType, eStoreLocation, eStoreName, findValue));
        }