Skip to content

Commit

Permalink
feat(templates): improve boilerplate test certificate #6694 (#6695)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi authored Jan 23, 2024
1 parent ad2fa4a commit e2d6a94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public static void AddIdentity(this IServiceCollection services, IConfiguration
var certificate = new X509Certificate2(certificatePath, appSettings.IdentitySettings.IdentityCertificatePassword, OperatingSystem.IsWindows() ? X509KeyStorageFlags.EphemeralKeySet : X509KeyStorageFlags.DefaultKeySet);

bool isBoilerplateTestCertificate = certificate.Thumbprint is "55140A8C935AB5202949071E5781E6946CD60606"; // The default test certificate is still in use
if (hostEnv.IsDevelopment() is false)
if (isBoilerplateTestCertificate && hostEnv.IsDevelopment() is false)
{
throw new InvalidOperationException(@"The default test certificate is still in use. Please replace it with a new one by running the 'dotnet dev-certs https --export-path IdentityCertificate.pfx --password P@ssw0rdP@ssw0rd' command in the server project's folder.");
throw new InvalidOperationException(@"The default test certificate is still in use. Please replace it with a new one by running the 'dotnet dev-certs https --export-path IdentityCertificate.pfx --password P@ssw0rdP@ssw0rd' command (or your preferred method for generating PFX files) in the server project's folder.");
}

services.AddDataProtection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
}</pre>
<div class="section-card-txt">
<b>Note</b>: IdentityCertificatePassword referring to the password of the
<b>IdentityCertificate.pfx</b> file in the Server project that used as certificate file
for store the public key and etc for validating incoming JWT tokens.
To create PFX file run the following commands in PowerShell with the desired password and file path for your pfx file.
<b>IdentityCertificate.pfx</b> file in the Server project.
To store the public key and other necessary information for validating incoming JWT tokens, a PFX file is employed.
The same PFX file is utilized to empower the ASP.NET Core Data Protection API.
Various methods exist for creating a PFX file. You may choose to follow your preferred approach for generating PFX files.
Alternatively, you can execute the following command, specifying the desired password and path for your PFX file.
</div>
<pre class="code-box">dotnet dev-certs https --export-path IdentityCertificate.pfx --password P@ssw0rdP@ssw0rd</pre>
<b>Note</b>: Replace P@ssw0rdP@ssw0rd with strong password and use that as IdentityCertificatePassword's value in appsettings.json
Expand Down

0 comments on commit e2d6a94

Please sign in to comment.