Fix incorrect path for the X509 certificates on Windows

refs #11449
This commit is contained in:
Gunnar Beutner 2016-04-01 11:40:01 +02:00 committed by Gunnar Beutner
parent c1a31afb3b
commit 909845c456
2 changed files with 17 additions and 9 deletions

View File

@ -45,7 +45,16 @@ namespace Icinga
}
}
public static void FatalError(Form owner, string message)
public static string Icinga2DataDir
{
get
{
return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2";
}
}
public static void FatalError(Form owner, string message)
{
MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
@ -69,7 +78,7 @@ namespace Icinga
Form form;
if (File.Exists(installDir + "\\etc\\icinga2\\features-enabled\\api.conf"))
if (File.Exists(Program.Icinga2DataDir + "\\etc\\icinga2\\features-enabled\\api.conf"))
form = new ServiceStatus();
else
form = new SetupWizard();

View File

@ -65,7 +65,7 @@ namespace Icinga
{
FileStream fp = null;
try {
fp = File.Open(Program.Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create);
fp = File.Open(Program.Icinga2DataDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create);
using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) {
fp = null;
sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature));
@ -144,8 +144,7 @@ namespace Icinga
{
SetRetrievalStatus(25);
string pathPrefix = Program.Icinga2InstallDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text;
string pathPrefix = Program.Icinga2DataDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text;
string output;
if (!File.Exists(pathPrefix + ".crt")) {
@ -355,8 +354,8 @@ namespace Icinga
thread.Start();
}
/*if (tbcPages.SelectedTab == tabParameters &&
!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) {
/*if (tbcPages.SelectedTab == tabParameters &&
!File.Exists(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) {
byte[] bytes = Convert.FromBase64String(txtBundle.Text);
MemoryStream ms = new MemoryStream(bytes);
GZipStream gz = new GZipStream(ms, CompressionMode.Decompress);
@ -368,10 +367,10 @@ namespace Icinga
ms2.Write(buffer, 0, rc);
ms2.Position = 0;
TarReader tr = new TarReader(ms2);
tr.ReadToEnd(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent");
tr.ReadToEnd(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent");
}*/
if (tbcPages.SelectedTab == tabConfigure) {
if (tbcPages.SelectedTab == tabConfigure) {
Thread thread = new Thread(ConfigureService);
thread.Start();
}