Skip to content

Commit

Permalink
Merge pull request #4406 from tstewart65/feature/signtool
Browse files Browse the repository at this point in the history
Adds two missing parameters for SignTool
  • Loading branch information
devlead authored Jan 2, 2025
2 parents 124704e + 2d3cbdb commit a79f454
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,34 @@ public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Use_Machine_Store
// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /sm /s \"Special Test Store\" \"/Working/a.dll\"", result.Args);
}

[Fact]
public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Cryptographic_Service_Provider()
{
// Given
var fixture = new SignToolSignRunnerFixture();
fixture.Settings.CspName = "Test Service Provider";

// When
var result = fixture.Run();

// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /csp \"Test Service Provider\" \"/Working/a.dll\"", result.Args);
}

[Fact]
public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Private_Key_Container_Name()
{
// Given
var fixture = new SignToolSignRunnerFixture();
fixture.Settings.PrivateKeyContainerName = "[{{password}}]=TestContainerName";

// When
var result = fixture.Run();

// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /kc \"[{{password}}]=TestContainerName\" \"/Working/a.dll\"", result.Args);
}
}
}
}
14 changes: 14 additions & 0 deletions src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,20 @@ private ProcessArgumentBuilder GetArguments(FilePath[] absoluteAssemblyPaths, Si
builder.AppendQuoted(settings.StoreName);
}

// Cryptographic Service Provider
if (!string.IsNullOrEmpty(settings.CspName))
{
builder.Append("/csp");
builder.AppendQuoted(settings.CspName);
}

// Private Key Container Name
if (!string.IsNullOrEmpty(settings.PrivateKeyContainerName))
{
builder.Append("/kc");
builder.AppendQuoted(settings.PrivateKeyContainerName);
}

// Target Assemblies to sign.
foreach (var path in absoluteAssemblyPaths)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Cake.Common/Tools/SignTool/SignToolSignSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,15 @@ public sealed class SignToolSignSettings : ToolSettings
/// Gets or sets the store to open when searching for the certificate.
/// </summary>
public string StoreName { get; set; }

/// <summary>
/// Gets or sets the cryptographic service provider (CSP) that contains the private key container.
/// </summary>
public string CspName { get; set; }

/// <summary>
/// Gets or sets the private key container name.
/// </summary>
public string PrivateKeyContainerName { get; set; }
}
}

0 comments on commit a79f454

Please sign in to comment.