Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] develop from cake-build:develop #37

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }
}
}
Loading