Skip to content

Commit dd07066

Browse files
committed
Merge remote-tracking branch 'origin/master' into xamarin-fix-uwp-login
2 parents 9ea68ae + 4dece91 commit dd07066

4 files changed

Lines changed: 49 additions & 2 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
using System.IO;
5+
using System.Reflection;
6+
using System.Security.Cryptography.X509Certificates;
7+
8+
namespace Identity.API.Certificate
9+
{
10+
static class Certificate
11+
{
12+
public static X509Certificate2 Get()
13+
{
14+
var assembly = typeof(Certificate).GetTypeInfo().Assembly;
15+
var names = assembly.GetManifestResourceNames();
16+
17+
/***********************************************************************************************
18+
* Please note that here we are using a local certificate only for testing purposes. In a
19+
* real environment the certificate should be created and stored in a secure way, which is out
20+
* of the scope of this project.
21+
**********************************************************************************************/
22+
using (var stream = assembly.GetManifestResourceStream("Identity.API.Certificate.idsrv3test.pfx"))
23+
{
24+
return new X509Certificate2(ReadStream(stream), "idsrv3test");
25+
}
26+
}
27+
28+
private static byte[] ReadStream(Stream input)
29+
{
30+
byte[] buffer = new byte[16 * 1024];
31+
using (MemoryStream ms = new MemoryStream())
32+
{
33+
int read;
34+
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
35+
{
36+
ms.Write(buffer, 0, read);
37+
}
38+
return ms.ToArray();
39+
}
40+
}
41+
}
42+
}
3.32 KB
Binary file not shown.

src/Services/Identity/Identity.API/Identity.API.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
1313
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
1414
</PropertyGroup>
15-
15+
1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
1818
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
@@ -57,6 +57,10 @@
5757
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
5858
</ItemGroup>
5959

60+
<ItemGroup>
61+
<EmbeddedResource Include="Certificate\idsrv3test.pfx" />
62+
</ItemGroup>
63+
6064
<ItemGroup>
6165
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
6266
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />

src/Services/Identity/Identity.API/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
1919
using Microsoft.AspNetCore.Identity;
2020
using Microsoft.Extensions.HealthChecks;
21+
using Identity.API.Certificate;
2122

2223
namespace eShopOnContainers.Identity
2324
{
@@ -75,7 +76,7 @@ public void ConfigureServices(IServiceCollection services)
7576

7677
// Adds IdentityServer
7778
services.AddIdentityServer(x => x.IssuerUri = "null")
78-
.AddTemporarySigningCredential()
79+
.AddSigningCredential(Certificate.Get())
7980
.AddInMemoryScopes(Config.GetScopes())
8081
.AddInMemoryClients(Config.GetClients(clientUrls))
8182
.AddAspNetIdentity<ApplicationUser>()

0 commit comments

Comments
 (0)