Skip to content

Commit

Permalink
revert: "fix(dotnet): strong-name sign assemblies (#2894)" (#2902)
Browse files Browse the repository at this point in the history
This reverts commit 7b90f27, and removes all support for .NET Strong-Name Signing, as this would be impossible to use as long as the `Amazon.Jsii.Runtime` assembly is not strong-name signed itself (which would be a breaking change to do!), since strong-name signed assemblies can only depend on other strong-name signed assemblies.
  • Loading branch information
RomainMuller authored Jul 9, 2021
1 parent e05ce62 commit 0006aee
Show file tree
Hide file tree
Showing 38 changed files with 19 additions and 246 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist/
*.tsbuildinfo
*.tabl.json
*.swp
*.snk
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ The `dotnet` target requires the following configuration:
transparent background is recommended. See the [.NET documentation] for more information.
- `versionSuffix` - an optional suffix that will be appended at the end of the NuGet package's `version` field. The
suffix must start with a `-`.
- `signAssembly` - whether the assembly should be strong-name signed. Defaults to `false` when not specified.
- `assemblyOriginatorKeyFile`- the path to the strong-name signing key to be used. When not specified or if the file
referred to does not exist, the assembly will not be strong-name signed.

Example:

Expand All @@ -21,8 +18,6 @@ Example:
"namespace": "Acme.HelloJsii", // Required
"packageId": "Acme.HelloJsii", // Required
"iconUrl": "https://cdn.acme.com/icon.png", // Optional
"signAssembly": true, // Optional
"assemblyOriginatorKeyFile": "./key.snk", // Optional
"versionSuffix": "-preview" // Optional
},
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<VSTestLogger>xunit</VSTestLogger>

<RollForward>Major</RollForward>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\dotnet-runtime\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 0 additions & 3 deletions packages/@jsii/dotnet-runtime/NuGet.Metadata.props.t.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ process.stdout.write(`<Project>
<IncludeSource>True</IncludeSource>
<PackageOutputPath>..\\..\\bin\\$(Configuration)\\NuGet\\</PackageOutputPath>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<SignAssembly Condition="Exists('$(AssemblyOriginatorKeyFile)')">True</SignAssembly>
</PropertyGroup>
</Project>
`);
Binary file removed packages/@jsii/dotnet-runtime/keypair.snk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<RollForward>Major</RollForward>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
CA1711, <!-- Identifiers should not have incorrect suffix -->
CA1724, <!-- Type names should not match namespaces -->
</NoWarn>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public void ShouldSerializeAllMembers()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
dependencies: new Dictionary<string, PackageVersion>(),
Expand Down Expand Up @@ -92,8 +90,6 @@ public void ShouldSerializeAllMembers()
""dotnet"": {
""namespace"": ""Dot.Net.Namespace"",
""packageId"": ""Dot.Net.PackageId"",
""signAssembly"": true,
""assemblyOriginatorKeyFile"": ""key.snk"",
""iconUrl"": ""http://www.example.com/icon.png""
}
}
Expand All @@ -120,8 +116,6 @@ public void ShouldThrowOnMissingName()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
dependencies: new Dictionary<string, PackageVersion>(),
Expand Down Expand Up @@ -149,8 +143,6 @@ public void ShouldThrowOnMissingVersion()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
types: new Dictionary<string, Amazon.JSII.JsonModel.Spec.Type>(),
Expand All @@ -176,8 +168,6 @@ public void ShouldNotSerializeMissingDependencies()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
types: new Dictionary<string, Amazon.JSII.JsonModel.Spec.Type>(),
Expand Down Expand Up @@ -210,8 +200,6 @@ public void ShouldNotSerializeMissingDependencies()
""dotnet"": {
""namespace"": ""Dot.Net.Namespace"",
""packageId"": ""Dot.Net.PackageId"",
""signAssembly"": true,
""assemblyOriginatorKeyFile"": ""key.snk"",
""iconUrl"": ""http://www.example.com/icon.png""
}
}
Expand All @@ -236,8 +224,6 @@ public void ShouldNotSerializeMissingBundled()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
types: new Dictionary<string, Amazon.JSII.JsonModel.Spec.Type>(),
Expand Down Expand Up @@ -270,8 +256,6 @@ public void ShouldNotSerializeMissingBundled()
""dotnet"": {
""namespace"": ""Dot.Net.Namespace"",
""packageId"": ""Dot.Net.PackageId"",
""signAssembly"": true,
""assemblyOriginatorKeyFile"": ""key.snk"",
""iconUrl"": ""http://www.example.com/icon.png""
}
}
Expand All @@ -296,8 +280,6 @@ public void ShouldNotSerializeMissingDocs()
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
packageId: "Dot.Net.PackageId",
signAssembly: true,
assemblyOriginatorKeyFile: "key.snk",
iconUrl: "http://www.example.com/icon.png"
)),
types: new Dictionary<string, Amazon.JSII.JsonModel.Spec.Type>(),
Expand Down Expand Up @@ -330,8 +312,6 @@ public void ShouldNotSerializeMissingDocs()
""dotnet"": {
""namespace"": ""Dot.Net.Namespace"",
""packageId"": ""Dot.Net.PackageId"",
""signAssembly"": true,
""assemblyOriginatorKeyFile"": ""key.snk"",
""iconUrl"": ""http://www.example.com/icon.png""
}
}
Expand Down Expand Up @@ -429,8 +409,6 @@ public void ShouldDeserializeAllMembersWithDotNetTarget()
""dotnet"": {
""namespace"": ""Dot.Net.Namespace"",
""packageId"": ""Dot.Net.PackageId"",
""signAssembly"": true,
""assemblyOriginatorKeyFile"": ""key.snk"",
""iconUrl"": ""http://www.example.com/icon.png""
},
""java"": { ""package"": ""com.amazonaws.cdk.Test"" }
Expand Down Expand Up @@ -463,8 +441,6 @@ public void ShouldDeserializeAllMembersWithDotNetTarget()
Assert.NotNull(dotNetTarget);
Assert.Equal("Dot.Net.Namespace", dotNetTarget?.Namespace);
Assert.Equal("Dot.Net.PackageId", dotNetTarget?.PackageId);
Assert.True(dotNetTarget?.SignAssembly);
Assert.Equal("key.snk", dotNetTarget?.AssemblyOriginatorKeyFile);
Assert.Equal("http://www.example.com/icon.png", dotNetTarget?.IconUrl);

Assert.Equal("myVersion", actual.Version, ignoreLineEndingDifferences: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@
CA1819, <!-- Properties should not return arrays -->
CA2225, <!-- Operator overloads have named alternates -->
</NoWarn>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NSubstitute" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Castle.Core.Internal;
using System;
using System.Runtime.CompilerServices;

[assembly:CLSCompliant(false)] // among other things, array parameters are passed to attributes

[assembly:InternalsVisibleTo("Amazon.JSII.Runtime.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d7206fa09e081f23fa91938ceede7b25c0dfb8010fa55038a859a3e0150f652e655b8f0d9c17c41bb1d2b2c5ee2eb6af43a930cd8e80c2d7fe7703b24e66a1c674f6328e44bda8000b5df4686d77be2aeef092da587672a7ca9b9a9502ad960bcb7f35154d9a855bf9db546daf79a34c9fb5ecb23c6291a92587d8ece0354e9c")]
[assembly:InternalsVisibleTo("Amazon.JSII.Runtime.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d7206fa09e081f23fa91938ceede7b25c0dfb8010fa55038a859a3e0150f652e655b8f0d9c17c41bb1d2b2c5ee2eb6af43a930cd8e80c2d7fe7703b24e66a1c674f6328e44bda8000b5df4686d77be2aeef092da587672a7ca9b9a9502ad960bcb7f35154d9a855bf9db546daf79a34c9fb5ecb23c6291a92587d8ece0354e9c")]
[assembly:InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)]
[assembly:InternalsVisibleTo("Amazon.JSII.Runtime.IntegrationTests")]
[assembly:InternalsVisibleTo("Amazon.JSII.Runtime.UnitTests")]
[assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")]
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public DotNetTarget
string @namespace,
string packageId,
string? title = null,
bool signAssembly = false,
string? assemblyOriginatorKeyFile = null,
string? iconUrl = null,
string? versionSuffix = null
)
Expand All @@ -33,8 +31,6 @@ public DotNetTarget
PackageId = packageId ?? throw new ArgumentNullException(nameof(packageId));

Title = title;
SignAssembly = signAssembly;
AssemblyOriginatorKeyFile = assemblyOriginatorKeyFile;
IconUrl = iconUrl;
VersionSuffix = versionSuffix;

Expand All @@ -53,12 +49,6 @@ public DotNetTarget
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string? Title { get; }

[JsonProperty("signAssembly", NullValueHandling = NullValueHandling.Ignore)]
public bool SignAssembly { get; }

[JsonProperty("assemblyOriginatorKeyFile", NullValueHandling = NullValueHandling.Ignore)]
public string? AssemblyOriginatorKeyFile { get; }

[JsonProperty("iconUrl", NullValueHandling = NullValueHandling.Ignore)]
public string? IconUrl { get; }

Expand Down
6 changes: 1 addition & 5 deletions packages/@jsii/kernel/test/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,10 @@ defineTest(
(sandbox) => {
expect(sandbox.naming({ assembly: 'jsii-calc' }).naming).toEqual({
dotnet: {
assemblyOriginatorKeyFile: 'keypair.snk',
iconUrl:
'https://sdk-for-net.amazonwebservices.com/images/AWSLogo128x128.png',
namespace: 'Amazon.JSII.Tests.CalculatorNamespace',
packageId: 'Amazon.JSII.Tests.CalculatorPackageId',
signAssembly: true,
},
go: {
moduleName: 'github.com/aws/jsii/jsii-calc/go',
Expand All @@ -414,11 +412,9 @@ defineTest(
expect(sandbox.naming({ assembly: '@scope/jsii-calc-lib' }).naming).toEqual(
{
dotnet: {
assemblyOriginatorKeyFile: 'keypair.snk',
namespace: 'Amazon.JSII.Tests.CalculatorNamespace.LibNamespace',
packageId: 'Amazon.JSII.Tests.CalculatorPackageId.LibPackageId',
versionSuffix: '-devpreview',
signAssembly: true,
},
go: {
moduleName: 'github.com/aws/jsii/jsii-calc/go',
Expand Down Expand Up @@ -2211,7 +2207,7 @@ async function preparePackage(module: string, useCache = true) {
}

const packageRoot = findPackageRoot(module);
await new Promise<void>((ok, ko) => {
await new Promise((ok, ko) => {
const child = childProcess.spawn('npm', ['pack', packageRoot], {
cwd: staging,
shell: true,
Expand Down
10 changes: 0 additions & 10 deletions packages/@jsii/spec/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ export interface Config {
* version field
*/
versionSuffix?: string;

/**
* whether the assembly should be strong-name signed
*/
signAssembly?: boolean;

/**
* path to the strong-name signing key to be used
*/
assemblyOriginatorFile?: string;
};
};

Expand Down
Binary file removed packages/@scope/jsii-calc-base-of-base/keypair.snk
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/@scope/jsii-calc-base-of-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
}
},
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"signAssembly": true,
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
},
Expand Down
6 changes: 2 additions & 4 deletions packages/@scope/jsii-calc-base-of-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
"schema": "jsii/0.10.0",
"targets": {
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId",
"signAssembly": true
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
},
"go": {
"moduleName": "github.com/aws/jsii/jsii-calc/go"
Expand Down Expand Up @@ -163,5 +161,5 @@
}
},
"version": "2.1.1",
"fingerprint": "L4CceIu37Nd8GLnVvLXQ62rAZvb7TNHW8E/k4n1CTLI="
"fingerprint": "rbtJN11MzD+pqofNrrkTb/GoS1wpG+lpZoOWh+HXysE="
}
Binary file removed packages/@scope/jsii-calc-base/keypair.snk
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/@scope/jsii-calc-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
}
},
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"signAssembly": true,
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BasePackageId"
},
Expand Down
10 changes: 3 additions & 7 deletions packages/@scope/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"@scope/jsii-calc-base-of-base": {
"targets": {
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId",
"signAssembly": true
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
},
"go": {
"moduleName": "github.com/aws/jsii/jsii-calc/go"
Expand Down Expand Up @@ -62,10 +60,8 @@
"schema": "jsii/0.10.0",
"targets": {
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BasePackageId",
"signAssembly": true
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BasePackageId"
},
"go": {
"moduleName": "github.com/aws/jsii/jsii-calc/go",
Expand Down Expand Up @@ -206,5 +202,5 @@
}
},
"version": "0.0.0",
"fingerprint": "sNbDXkJP4A5egmiid9p5XJ6TF4X3EgfegVxhtaN5Kco="
"fingerprint": "rIJAOTzUs2OYke2UCJzexq/fqJOiqmR9PbTMlf37o/A="
}
Binary file removed packages/@scope/jsii-calc-lib/keypair.snk
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/@scope/jsii-calc-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
}
},
"dotnet": {
"assemblyOriginatorKeyFile": "keypair.snk",
"signAssembly": true,
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.LibNamespace",
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.LibPackageId",
"versionSuffix": "-devpreview"
Expand Down
Loading

0 comments on commit 0006aee

Please sign in to comment.