Skip to content

Commit

Permalink
Merge pull request #103 from ITfoxtec/development
Browse files Browse the repository at this point in the history
Certificates folder
  • Loading branch information
Revsgaard authored Dec 3, 2024
2 parents be1ae7b + c2469ab commit 3d33b35
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/AspNetCoreApi1Sample/AspNetCoreApi1Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<None Update="CN=AspNetCoreApi1Sample, O=test corp.cer">
<None Update="Certificates\CN=AspNetCoreApi1Sample, O=test corp.cer">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
29 changes: 15 additions & 14 deletions src/AspNetCoreApi1Sample/Controllers/ValuesApi2Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,26 @@ private async Task<string> GetTokenForApi2()

private X509Certificate2 GetClientCertificate()
{
try
if (!identitySettings.TokenExchangeClientCertificateThumbprint.IsNullOrEmpty())
{
if (!identitySettings.TokenExchangeClientCertificateThumbprint.IsNullOrEmpty())
{
return CertificateUtil.Load(StoreName.My, StoreLocation.CurrentUser, X509FindType.FindByThumbprint, identitySettings.TokenExchangeClientCertificateThumbprint);
}
else
{
return CertificateUtil.Load(Path.Combine(Startup.AppEnvironment.ContentRootPath, identitySettings.TokenExchangeClientCertificateFile), identitySettings.TokenExchangeClientCertificatePassword);
}
return CertificateUtil.Load(StoreName.My, StoreLocation.CurrentUser, X509FindType.FindByThumbprint, identitySettings.TokenExchangeClientCertificateThumbprint);
}
catch (Exception ex)
else
{
foreach (var path in Directory.GetFiles(Startup.AppEnvironment.ContentRootPath))
var parth = Path.Combine(Startup.AppEnvironment.ContentRootPath, "Certificates");
try
{
return CertificateUtil.Load(Path.Combine(parth, identitySettings.TokenExchangeClientCertificateFile), identitySettings.TokenExchangeClientCertificatePassword);
}
catch (Exception ex)
{
Console.WriteLine(path); // full path
Console.WriteLine(Path.GetFileName(path)); // file name
foreach (var path in Directory.GetFiles(Startup.AppEnvironment.ContentRootPath))
{
Console.WriteLine(path); // full path
Console.WriteLine(Path.GetFileName(path)); // file name
}
throw new Exception($"Load certificate '{identitySettings.TokenExchangeClientCertificateFile}' error, path '{parth}'.", ex);
}
throw new Exception($"Load certificate '{identitySettings.TokenExchangeClientCertificateFile}' error, path '{Startup.AppEnvironment.ContentRootPath}'.", ex);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreApi1Sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ RUN dotnet publish "AspNetCoreApi1Sample.csproj" -c $BUILD_CONFIGURATION -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY "src/AspNetCoreApi1Sample/CN=AspNetCoreApi1Sample, O=test corp.pfx" .
COPY "src/AspNetCoreApi1Sample/Certificates/." .
ENTRYPOINT ["dotnet", "AspNetCoreApi1Sample.dll"]
2 changes: 1 addition & 1 deletion src/AspNetCoreApi2Sample/AspNetCoreApi2Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreSamlIdPSample/AspNetCoreSamlIdPSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ExternalLoginApiSample/ExternalLoginApiSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down

0 comments on commit 3d33b35

Please sign in to comment.