Example #1
0
        public static string sMachineKeyPathFile(tvProfile aoProfile, X509Certificate2 aoCertificate)
        {
            string lsMachineKeyPathFile = null;

            try
            {
                lsMachineKeyPathFile = Path.Combine(aoProfile.sValue("-MachineKeysPath", @"C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys")
                                                    , HashClass.GetKeyFileName(aoCertificate));
            }
            catch (InvalidOperationException ex)
            {
                if (aoProfile.bValue("-DeclareErrorOnPrivateKeyFileCleanedUp", false))
                {
                    Type ltDoGetCert = Type.GetType("DoGetCert");
                    if (null == ltDoGetCert)
                    {
                        throw ex;
                    }
                    else
                    {
                        ltDoGetCert.GetMethod("LogIt").Invoke(null, new object[] {
                            String.Format("GetCertServiceFault: {0}{1}{2}{3}"
                                          , ex.Message, (null == ex.InnerException ? "": "; " + ex.InnerException.Message)
                                          , Environment.NewLine
                                          , ex.StackTrace)
                        });
                    }
                }
            }

            return(lsMachineKeyPathFile);
        }
Example #2
0
        public static string sMachineKeyPathFile(tvProfile aoProfile, X509Certificate2 aoCertificate)
        {
            string lsMachineKeyPathFile = null;

            try
            {
                lsMachineKeyPathFile = Path.Combine(aoProfile.sValue("-MachineKeysPath", @"C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys")
                                                    , HashClass.GetKeyFileName(aoCertificate));
            }
            catch (InvalidOperationException ex)
            {
                if (aoProfile.bValue("-DeclareErrorOnPrivateKeyFileCleanedUp", false))
                {
                    DoGetCert.LogIt(aoProfile, DoGetCert.sExceptionMessage(ex));
                }
            }

            return(lsMachineKeyPathFile);
        }