private bool checkCaPassword1(string password, string CA) { bool flag = true; if ((CA.Length == 0) || (password.Length == 0)) { return(false); } try { if (DigitalEnvelop.DigEnvInit(false, true, true) == 0) { try { string str = PropertyUtil.GetValue("MAIN_PATH") + @"\bin\server.pfx"; string currentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(PropertyUtil.GetValue("MAIN_PATH") + @"\bin\"); int num = DigitalEnvelop.SetCaCertAndCrlByPfx(CA, password, ""); this.loger.Info("GetCurrentDirectory :" + currentDirectory); this.loger.Info("m_strPfxPath :" + str); this.loger.Info(" DigitalEnvelop.SetCaCertAndCrlByPfx ret :" + num.ToString()); Directory.SetCurrentDirectory(currentDirectory); if ((num != 0) && (num == 2)) { flag = false; } } catch (Exception exception) { this.loger.Error("校验证书密码发生异常:" + exception.ToString()); string[] textArray1 = new string[] { exception.ToString() }; MessageManager.ShowMsgBox("SWDK-0061", textArray1); return(false); } } DigitalEnvelop.DigEnvClose(); } catch (Exception exception2) { this.loger.Error("校验证书密码发生异常:" + exception2.ToString()); string[] textArray2 = new string[] { exception2.ToString() }; MessageManager.ShowMsgBox("SWDK-0061", textArray2); return(false); } return(flag); }
private bool checkCaPassword(string password, string CA) { bool flag = true; if ((CA.Length == 0) || (password.Length == 0)) { return(false); } try { string path = PropertyUtil.GetValue("MAIN_PATH") + @"\bin\CAConsole.exe"; string str2 = PropertyUtil.GetValue("MAIN_PATH") + @"\bin\server.pfx"; string currentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(PropertyUtil.GetValue("MAIN_PATH") + @"\bin\"); this.loger.Info("GetCurrentDirectory :" + currentDirectory); this.loger.Info("m_strPfxPath :" + str2); if (File.Exists("caResult.dat")) { File.Delete("caResult.dat"); } if (File.Exists(path)) { Process process = new Process { StartInfo = { FileName = path, Arguments = password, UseShellExecute = true, WindowStyle = ProcessWindowStyle.Hidden } }; process.Start(); process.WaitForExit(); Thread.Sleep(0x3e8); if (process.HasExited) { if (File.Exists("caResult.dat")) { StreamReader reader = new StreamReader(File.Open("caResult.dat", FileMode.Open), ToolUtil.GetEncoding()); string str4 = ""; while ((str4 = reader.ReadLine()) != null) { this.loger.Info(" caResult.dat Line :" + str4); if (str4.IndexOf("return=0") == -1) { flag = false; } } } else { string[] textArray1 = new string[] { "caResult.dat文件未找到" }; MessageManager.ShowMsgBox("SWDK-0061", textArray1); flag = false; } } else if (!process.HasExited) { process.Kill(); flag = false; } } Directory.SetCurrentDirectory(currentDirectory); } catch (Exception exception) { this.loger.Error("校验证书密码发生异常:" + exception.ToString()); string[] textArray2 = new string[] { exception.ToString() }; MessageManager.ShowMsgBox("SWDK-0061", textArray2); return(false); } DigitalEnvelop.DigEnvClose(); return(flag); }