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
parent 1fb0907bc4
commit 3715f307a1
2 changed files with 17 additions and 8 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); MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit(); Application.Exit();
@ -69,7 +78,7 @@ namespace Icinga
Form form; 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(); form = new ServiceStatus();
else else
form = new SetupWizard(); form = new SetupWizard();

View File

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