Skip to content

Commit

Permalink
Code cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Feb 13, 2023
1 parent a0057d5 commit e5a021c
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Samples/CertbotSample/CertbotSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TlsCertificateLoader" Version="2.2.8" />
<PackageReference Include="TlsCertificateLoader" Version="2.2.9" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/CertbotSample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ certbot certonly --standalone

You need to do this twice, once for the domain and once for the www subdomain.

If you want you can switch [Certbot](https://certbot.eff.org/) to use --webroot instead, which you can set to the path of the wwwroot folder.
If you want you can switch [Certbot](https://certbot.eff.org/) to use --webroot instead, which you can set to the path of the wwwroot folder.
5 changes: 0 additions & 5 deletions Samples/CertbotSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Net.Http.Headers;
using System;
using System.Runtime.Versioning;

namespace CertbotSample
{
public class Startup
{
public Startup()
{
}

public void ConfigureServices(IServiceCollection services)
{
services.AddHsts(options =>
Expand Down
4 changes: 2 additions & 2 deletions Samples/CertbotSample/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class Worker : IWorker
private void ChangeToken(PhysicalFileProvider physicalFileProvider, bool isWww)
{
var fileChangeToken = physicalFileProvider.Watch("privkey*.pem");
fileChangeToken.RegisterChangeCallback(CertificatesRefreshed, isWww);
fileChangeToken.RegisterChangeCallback(async (state) => await CertificatesRefreshed(state).ConfigureAwait(false), isWww);
}

private async void CertificatesRefreshed(object state)
private async Task CertificatesRefreshed(object state)
{
var isWww = Convert.ToBoolean(state);
await Task.Delay(5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TlsCertificateLoader" Version="2.2.8" />
<PackageReference Include="TlsCertificateLoader" Version="2.2.9" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/CertbotSampleUsingMiddleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ certbot certonly --standalone

You need to do this twice, once for the domain and once for the www subdomain.

If you want you can switch [Certbot](https://certbot.eff.org/) to use --webroot instead, which you can set to the path of the wwwroot folder.
If you want you can switch [Certbot](https://certbot.eff.org/) to use --webroot instead, which you can set to the path of the wwwroot folder.
2 changes: 1 addition & 1 deletion TlsCertificateLoader/Extensions/ListenOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static ListenOptions SetHttpsConnectionAdapterOptions(this ListenOptions
{
return listenOptions.UseHttps(new HttpsConnectionAdapterOptions
{
ServerCertificateSelector = (context, hostname) => tlsCertificateLoader.GetCertificateHolder(hostname).X509Certificate2
ServerCertificateSelector = (_, hostname) => tlsCertificateLoader.GetCertificateHolder(hostname).X509Certificate2
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public static IApplicationBuilder UseTlsCertificateLoader(this IApplicationBuild
if (uri.StartsWith("/.well-known"))
{
await next();
return;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TlsCertificateLoaderHstsOptions : HstsOptions
/// <summary>
/// <inheritdoc cref="HstsOptions.IncludeSubDomains"/>
/// </summary>
public new bool IncludeSubDomains { get; set; } = false;
public new bool IncludeSubDomains { get; set; }
/// <summary>
/// <inheritdoc cref="HstsOptions.Preload"/> Defaults to <see langword="true"/>.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions TlsCertificateLoader/TlsCertificateLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<PackageProjectUrl>https://github.com/MarkCiliaVincenti/TlsCertificateLoader</PackageProjectUrl>
<Copyright>MIT</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>2.2.8</Version>
<Version>2.2.9</Version>
<PackageIcon>logo.png</PackageIcon>
<PackageReleaseNotes>Enabled deterministic builds, allowing debugging of this library from your code.</PackageReleaseNotes>
<PackageReleaseNotes>Code cleaning.</PackageReleaseNotes>
<Description>Allows loading of TLS (HTTPS) certificates for .NET 6.0/7.0 Kestrel web applications, allowing for refreshing of certificates as well as compatibility with HTTP/3. Includes optional middleware for using certificates obtained by Certbot.</Description>
<Copyright>© 2022 Mark Cilia Vincenti</Copyright>
<PackageTags>HTTPS,TLS,SSL,Kestrel,HTTP3,HTTP/3,certificates,security,net6,net6.0,net7,net7.0,Certbot,aspnetcore,middleware</PackageTags>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>2.2.8.0</AssemblyVersion>
<FileVersion>2.2.8.0</FileVersion>
<AssemblyVersion>2.2.9.0</AssemblyVersion>
<FileVersion>2.2.9.0</FileVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IsPackable>true</IsPackable>
<IsTrimmable>true</IsTrimmable>
Expand Down
4 changes: 2 additions & 2 deletions TlsCertificateLoader/Workers/CertbotCertificateRefresher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ internal sealed class CertbotCertificateRefresher : ICertbotCertificateRefresher
private void ChangeToken(PhysicalFileProvider physicalFileProvider, bool isWww)
{
var fileChangeToken = physicalFileProvider.Watch("privkey*.pem");
fileChangeToken.RegisterChangeCallback(CertificatesRefreshed, isWww);
fileChangeToken.RegisterChangeCallback(async (state) => await CertificatesRefreshed(state).ConfigureAwait(false), isWww);
}

private async void CertificatesRefreshed(object state)
private async Task CertificatesRefreshed(object state)
{
var isWww = Convert.ToBoolean(state);
await Task.Delay(5000);
Expand Down

0 comments on commit e5a021c

Please sign in to comment.