Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cfb6dd1
Add service addition functionality to ServiceProviderFactory
clairernovotny Dec 11, 2024
30cf2cd
Refactor TrustedSigningService for DI and add Azure support
clairernovotny Dec 11, 2024
bf49764
cleanup
clairernovotny Dec 11, 2024
b23dbea
Rename private field `servicesToAdd` to `_servicesToAdd`
clairernovotny Dec 11, 2024
69a9cdf
Fix parameter name in test
clairernovotny Dec 11, 2024
41b08eb
Some formatting and renames based on feedback
clairernovotny Dec 11, 2024
6771ae1
Update editorconfig to match VS output, add additioal rules and sort …
clairernovotny Dec 11, 2024
991901d
Wrapped the Stream object in a using statement to ensure it is proper…
clairernovotny Dec 12, 2024
b76bd5b
Enhance Azure Key Vault integration
clairernovotny Dec 12, 2024
7f3a169
Add additional logging
clairernovotny Dec 12, 2024
92d6692
Refactor KeyVaultService and update tests
clairernovotny Dec 12, 2024
808959c
Update tests
clairernovotny Dec 13, 2024
0b2abdd
Finish tests
clairernovotny Dec 13, 2024
23f8be2
Revert editorconfig update. separate pr for that
clairernovotny Dec 13, 2024
a65bd80
Update src/Sign.SignatureProviders.TrustedSigning/Resources.resx
clairernovotny Dec 13, 2024
9bba4f3
Ensure the cert details are printed on a new line
clairernovotny Dec 13, 2024
e6f51ab
Handle the error with a better output message instead of a stack trac…
clairernovotny Dec 13, 2024
d2407d3
Apply feedback.
dtivel Feb 11, 2025
cff5177
Bump dependency version.
dtivel Feb 11, 2025
d715764
Apply feedback.
dtivel Feb 11, 2025
9836878
Add test
dtivel Feb 13, 2025
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
Prev Previous commit
Next Next commit
Apply feedback.
  • Loading branch information
dtivel committed Feb 11, 2025
commit d2407d384df9cdc099433d4416691fda239a6b5d
3 changes: 0 additions & 3 deletions src/Sign.Cli/AzureKeyVaultCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.IO;

using Azure.Core;
using Azure.Security.KeyVault.Certificates;
using Azure.Security.KeyVault.Keys;
using Azure.Security.KeyVault.Keys.Cryptography;

using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using Sign.Core;
using Sign.SignatureProviders.KeyVault;

Expand Down
12 changes: 5 additions & 7 deletions src/Sign.Cli/TrustedSigningCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.IO;

using Azure.CodeSigning;
using Azure.CodeSigning.Extensions;
using Azure.Core;

using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using Sign.Core;
using Sign.SignatureProviders.TrustedSigning;

Expand Down Expand Up @@ -57,6 +54,7 @@ internal TrustedSigningCommand(CodeCommand codeCommand, IServiceProviderFactory
}

TokenCredential? credential = AzureCredentialOptions.CreateTokenCredential(context);

if (credential is null)
{
return;
Expand All @@ -80,10 +78,10 @@ internal TrustedSigningCommand(CodeCommand codeCommand, IServiceProviderFactory
services.AddSingleton<TrustedSigningService>(serviceProvider =>
{
return new TrustedSigningService(
serviceProvider.GetRequiredService<CertificateProfileClient>(),
accountName,
certificateProfileName,
serviceProvider.GetRequiredService<ILogger<TrustedSigningService>>());
serviceProvider.GetRequiredService<CertificateProfileClient>(),
accountName,
certificateProfileName,
serviceProvider.GetRequiredService<ILogger<TrustedSigningService>>());
});
});

Expand Down
2 changes: 0 additions & 2 deletions src/Sign.Core/DataFormatSigners/AzureSignToolSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
using System.Globalization;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

using AzureSign.Core;

using Microsoft.Extensions.Logging;

namespace Sign.Core
Expand Down
3 changes: 1 addition & 2 deletions src/Sign.Core/Signer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -192,4 +191,4 @@ private static string ExpandFilePath(DirectoryInfo baseDirectory, string file)
return file;
}
}
}
}
4 changes: 3 additions & 1 deletion src/Sign.Core/SigningException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

namespace Sign.Core
{
internal class SigningException : Exception
internal sealed class SigningException : Exception
{
public SigningException()
{
}

public SigningException(string message)
: base(message)
{
}

public SigningException(string message, Exception inner)
: base(message, inner)
{
Expand Down
1 change: 0 additions & 1 deletion src/Sign.Core/Tools/NuGet/NuGetSignatureProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Text;

using NuGet.Common;
using NuGet.Packaging.Signing;

Expand Down
3 changes: 0 additions & 3 deletions src/Sign.SignatureProviders.KeyVault/KeyVaultService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

using Azure;
using Azure.Security.KeyVault.Certificates;
using Azure.Security.KeyVault.Keys.Cryptography;

using Microsoft.Extensions.Logging;

using Sign.Core;

namespace Sign.SignatureProviders.KeyVault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE.txt file in the project root for more information.

using Microsoft.Extensions.DependencyInjection;

using Sign.Core;

namespace Sign.SignatureProviders.KeyVault
Expand Down
2 changes: 1 addition & 1 deletion src/Sign.SignatureProviders.KeyVault/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CertificateDetails" xml:space="preserve">
<value>Certificate Details:</value>
<value>Certificate details:</value>
</data>
<data name="FetchedCertificate" xml:space="preserve">
<value>Fetched certificate. [{milliseconds} ms]</value>
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="cs" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="de" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="es" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="fr" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="it" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="ja" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="ko" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="pl" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="pt-BR" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="ru" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
4 changes: 2 additions & 2 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="tr" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:</source>
<target state="new">Certificate Details:</target>
<source>Certificate details:</source>
<target state="new">Certificate details:</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

using Azure;
using Azure.CodeSigning;

using Microsoft.Extensions.Logging;

using Sign.Core;

namespace Sign.SignatureProviders.TrustedSigning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE.txt file in the project root for more information.

using Microsoft.Extensions.DependencyInjection;

using Sign.Core;

namespace Sign.SignatureProviders.TrustedSigning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using Sign.Core;

namespace Sign.Cli.Test
Expand Down
7 changes: 3 additions & 4 deletions test/Sign.Core.Test/ServiceProviderFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void AddService_ServicesIsNull_Throws()
}

[Fact]
public void AddServices_AddedServicesAreAdded()
public void AddServices_WhenServicesAreNotAlreadyPresent_AddsServices()
{
var factory = new ServiceProviderFactory();
factory.AddServices(services => services.AddSingleton<ITestService, TestService>());
Expand All @@ -30,7 +30,7 @@ public void AddServices_AddedServicesAreAdded()
}

[Fact]
public void AddServices_AddedIfAddedServicesAreAlsoPresent()
public void AddServices_WhenServiceIsAlreadyPresent_AddsOnlyNewService()
{
var factory = new ServiceProviderFactory();
factory.AddServices(services => services.AddSingleton<ITestService, TestService>());
Expand All @@ -40,13 +40,12 @@ public void AddServices_AddedIfAddedServicesAreAlsoPresent()
}

[Fact]
public void Create_NoAddedServices()
public void Create_WhenNoServicesAdded_ReturnsDefault()
{
var factory = new ServiceProviderFactory();
IServiceProvider serviceProvider = factory.Create();
Assert.NotNull(serviceProvider.GetRequiredService<ILogger<ServiceProviderFactoryTests>>());
}

}

public interface ITestService
Expand Down
Loading
Loading