Skip to content

Commit

Permalink
Fix incorrect path for the X509 certificates on Windows
Browse files Browse the repository at this point in the history
refs #11449
  • Loading branch information
gunnarbeutner committed Apr 20, 2016
1 parent c1a31af commit 909845c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 11 additions & 2 deletions agent/windows-setup-agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ public static string Icinga2InstallDir
}
}

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();
Expand All @@ -69,7 +78,7 @@ static void Main()

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();
Expand Down
13 changes: 6 additions & 7 deletions agent/windows-setup-agent/SetupWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void EnableFeature(string feature)
{
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));
Expand Down Expand Up @@ -144,8 +144,7 @@ private void VerifyCertificate(string host, string port)
{
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")) {
Expand Down Expand Up @@ -355,8 +354,8 @@ private void tbcPages_SelectedIndexChanged(object sender, EventArgs e)
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);
Expand All @@ -368,10 +367,10 @@ private void tbcPages_SelectedIndexChanged(object sender, EventArgs e)
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();
}
Expand Down

0 comments on commit 909845c

Please sign in to comment.