Skip to content

Commit

Permalink
(#977) Ensure that the correct public key is used
Browse files Browse the repository at this point in the history
When attempting to load the Chocolatey GUI Licensed Extension assembly,
we need to ensure that the correct public key token is used.  In
previous versions of Chocolatey.Lib, the resolve_or_load_assembly
method made assumptions that meant that this wasn't necessary, but a
recent change over there has meant that it is now required.

Without passing in this information, the Chocolatey GUI Licensed
Extension assembly can't be located, and as a result, none of the
licensed functionality currently works within Chocolatey GUI.
  • Loading branch information
gep13 committed Jan 26, 2023
1 parent 3b5d4e4 commit 5e440fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Source/ChocolateyGui.Common.Windows/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ protected override void Configure()

Logger = Log.Logger = logConfig.CreateLogger();

Container = AutoFacConfiguration.RegisterAutoFac(LicensedChocolateyGuiAssemblySimpleName, LicensedGuiAssemblyLocation);
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
var chocolateyGuiPublicKey = OfficialChocolateyGuiPublicKey;
#else
var chocolateyGuiPublicKey = UnofficialChocolateyGuiPublicKey;
#endif

Container = AutoFacConfiguration.RegisterAutoFac(LicensedChocolateyGuiAssemblySimpleName, LicensedGuiAssemblyLocation, chocolateyGuiPublicKey);
}

protected override async void OnStartup(object sender, StartupEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions Source/ChocolateyGui.Common/Startup/AutoFacConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class AutoFacConfiguration
"Microsoft.Maintainability",
"CA1506:AvoidExcessiveClassCoupling",
Justification = "This is really a requirement due to required registrations.")]
public static IContainer RegisterAutoFac(string chocolateyGuiAssemblySimpleName, string licensedGuiAssemblyLocation)
public static IContainer RegisterAutoFac(string chocolateyGuiAssemblySimpleName, string licensedGuiAssemblyLocation, string publicKey)
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyModules(System.Reflection.Assembly.GetCallingAssembly());
Expand All @@ -32,7 +32,7 @@ public static IContainer RegisterAutoFac(string chocolateyGuiAssemblySimpleName,
{
var licensedGuiAssembly = AssemblyResolution.resolve_or_load_assembly(
chocolateyGuiAssemblySimpleName,
chocolatey.infrastructure.app.ApplicationParameters.OfficialChocolateyPublicKey,
publicKey,
licensedGuiAssemblyLocation);

if (licensedGuiAssembly != null)
Expand Down
8 changes: 7 additions & 1 deletion Source/ChocolateyGuiCli/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ internal static void Configure()

Logger = Log.Logger = logConfig.CreateLogger();

Container = AutoFacConfiguration.RegisterAutoFac(LicensedChocolateyGuiAssemblySimpleName, LicensedGuiAssemblyLocation);
#if FORCE_CHOCOLATEY_OFFICIAL_KEY
var chocolateyGuiPublicKey = OfficialChocolateyGuiPublicKey;
#else
var chocolateyGuiPublicKey = UnofficialChocolateyGuiPublicKey;
#endif

Container = AutoFacConfiguration.RegisterAutoFac(LicensedChocolateyGuiAssemblySimpleName, LicensedGuiAssemblyLocation, chocolateyGuiPublicKey);
}
}
}

0 comments on commit 5e440fe

Please sign in to comment.