diff --git a/Constants.cs b/Constants.cs
new file mode 100644
index 0000000..cc4b9e8
--- /dev/null
+++ b/Constants.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Garry.Control4.Jailbreak
+{
+ public static class Constants
+ {
+ public const int Version = 1;
+
+ ///
+ /// The cert for composer needs to be named cacert-*.pem
+ ///
+ public const string ComposerCertName = "cacert-garry.pem";
+
+ ///
+ /// Needs to start with Composer_ and can be anything after
+ ///
+ public const string CertificateCN = "Composer_GarryComposerMod";
+
+ ///
+ /// Should always be this unless they change something internally
+ ///
+ public const string CertPassword = "R8lvpqtgYiAeyO8j8Pyd";
+
+ ///
+ /// How many days until the certificate expires. Doesn't seem any harm in setting this to
+ /// a huge value so you don't have to re-crack every year.
+ ///
+ public const int CertificateExpireDays = 3650;
+
+ ///
+ /// Where OpenSSL is installed (it's installed with Composer)
+ ///
+ public const string OpenSslExe = @"C:\Program Files (x86)\Control4\Composer\Pro\RemoteAccess\bin\openssl.exe";
+
+ ///
+ /// Where OpenSSL's Config is located (it's installed with Composer)
+ ///
+ public const string OpenSslConfig = @"C:\Program Files (x86)\Control4\Composer\Pro\RemoteAccess\config\openssl.cfg";
+ }
+}
diff --git a/Control4.Jailbreak.csproj b/Control4.Jailbreak.csproj
index 8673c6b..b7c3ec3 100644
--- a/Control4.Jailbreak.csproj
+++ b/Control4.Jailbreak.csproj
@@ -91,6 +91,7 @@
+
True
True
diff --git a/UI/DirectorPatch.cs b/UI/DirectorPatch.cs
index 24d02af..fa222c0 100644
--- a/UI/DirectorPatch.cs
+++ b/UI/DirectorPatch.cs
@@ -66,7 +66,7 @@ bool GenerateCertificates( LogWindow log )
// Don't regenerate the certificates. They might be copying the folder
// over to another computer or some shit.
//
- if ( System.IO.File.Exists( $"Certs/cacert-garry.pem" ) &&
+ if ( System.IO.File.Exists( $"Certs/{Constants.ComposerCertName}" ) &&
System.IO.File.Exists( $"Certs/composer.p12" ) &&
System.IO.File.Exists( $"Certs/private.key" ) &&
System.IO.File.Exists( $"Certs/public.pem" ) )
@@ -78,17 +78,15 @@ bool GenerateCertificates( LogWindow log )
return true;
}
- var openssl = @"C:\Program Files (x86)\Control4\Composer\Pro\RemoteAccess\bin\openssl.exe";
- if ( !System.IO.File.Exists( openssl ) )
+ if ( !System.IO.File.Exists( Constants.OpenSslExe ) )
{
- log.WriteError( $"Couldn't find {openssl} - do you have composer installed?" );
+ log.WriteError( $"Couldn't find {Constants.OpenSslExe} - do you have composer installed?" );
return false;
}
- var config = @"C:\Program Files (x86)\Control4\Composer\Pro\RemoteAccess\config\openssl.cfg";
- if ( !System.IO.File.Exists( openssl ) )
+ if ( !System.IO.File.Exists( Constants.OpenSslConfig ) )
{
- log.WriteError( $"Couldn't find {config} - do you have composer installed?" );
+ log.WriteError( $"Couldn't find {Constants.OpenSslConfig} - do you have composer installed?" );
return false;
}
@@ -102,11 +100,11 @@ bool GenerateCertificates( LogWindow log )
// generate a self signed private and public key
//
log.WriteNormal( "\nGenerating private + public keys\n" );
- var exitCode = RunProcessPrintOutput( log, openssl, $"req -new -x509 -sha256 -nodes -days 3650 -newkey rsa:1024 -keyout \"Certs/private.key\" -subj \"/C=US/ST=Utah/L=Draper/O=Control4/OU=Controller Certificates/CN=Composer_GarryComposerMod/\" -out \"Certs/public.pem\" -config \"{config}\"" );
+ var exitCode = RunProcessPrintOutput( log, Constants.OpenSslExe, $"req -new -x509 -sha256 -nodes -days {Constants.CertificateExpireDays} -newkey rsa:1024 -keyout \"Certs/private.key\" -subj \"/C=US/ST=Utah/L=Draper/O=Control4/OU=Controller Certificates/CN={Constants.CertificateCN}/\" -out \"Certs/public.pem\" -config \"{Constants.OpenSslConfig}\"" );
if ( exitCode != 0 )
{
- MessageBox.Show( $"Couldn't find {config} - do you have composer installed?", "Openssl.cfg not found", MessageBoxButtons.OK, MessageBoxIcon.Error );
+ log.WriteError( $"Failed." );
return false;
}
@@ -114,20 +112,20 @@ bool GenerateCertificates( LogWindow log )
// Create the composer.p12 (public key) which sits in your composer config folder
//
log.WriteNormal( "Creating composer.p12\n" );
- exitCode = RunProcessPrintOutput( log, openssl, $"pkcs12 -export -out \"Certs/composer.p12\" -inkey \"Certs/private.key\" -in \"Certs/public.pem\" -passout pass:R8lvpqtgYiAeyO8j8Pyd" );
+ exitCode = RunProcessPrintOutput( log, Constants.OpenSslExe, $"pkcs12 -export -out \"Certs/composer.p12\" -inkey \"Certs/private.key\" -in \"Certs/public.pem\" -passout pass:{Constants.CertPassword}" );
if ( exitCode != 0 )
{
- MessageBox.Show( $"Couldn't find {config} - do you have composer installed?", "Openssl.cfg not found", MessageBoxButtons.OK, MessageBoxIcon.Error );
+ log.WriteError( $"Failed." );
return false;
}
//
- // Get the text for the composer cacert-garry.pem
+ // Get the text for the composer cacert-*.pem
//
- log.WriteNormal( "Creating cacert-garry.pem\n" );
- var output = RunProcessGetOutput( openssl, $"x509 -in \"Certs/public.pem\" -text" );
- System.IO.File.WriteAllText( "Certs/cacert-garry.pem", output );
+ log.WriteNormal( $"Creating {Constants.ComposerCertName}\n" );
+ var output = RunProcessGetOutput( Constants.OpenSslExe, $"x509 -in \"Certs/public.pem\" -text" );
+ System.IO.File.WriteAllText( $"Certs/{Constants.ComposerCertName}", output );
return true;
@@ -137,7 +135,7 @@ bool PatchComposer( LogWindow log )
{
var configFolder = $"{Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData )}\\Control4\\Composer";
- CopyFile( log, $"Certs/cacert-garry.pem", $"{configFolder}\\cacert-garry.pem" );
+ CopyFile( log, $"Certs/{Constants.ComposerCertName}", $"{configFolder}\\{Constants.ComposerCertName}" );
CopyFile( log, $"Certs/composer.p12", $"{configFolder}\\composer.p12" );
return true;
diff --git a/UI/MainWindow.cs b/UI/MainWindow.cs
index 8387b67..f828688 100644
--- a/UI/MainWindow.cs
+++ b/UI/MainWindow.cs
@@ -24,6 +24,8 @@ public MainWindow()
{
InitializeComponent();
+ this.Text += $" - v{Constants.Version}";
+
MainTabControl.TabPages.Clear();
Director = new Director( this );