Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Publish WinCertInstaller
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
run: dotnet publish WinCertInstaller/WinCertInstaller.csproj -c Release -r win-x64 --self-contained false -p:PublishSingleFile=true -o ./publish
run: dotnet publish WinCertInstaller/WinCertInstaller.csproj -c Release -r win-x64 -o ./publish

- name: Upload Artifact
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
Expand All @@ -48,6 +48,6 @@ jobs:
shell: pwsh
run: |
$tag = $env:GITHUB_REF -replace 'refs/tags/', ''
gh release create $tag ./publish/WinCertInstaller.exe ./publish/appsettings.json --title "Release $tag" --notes "Automated release for version $tag"
gh release create $tag ./publish/WinCertInstaller.exe --title "Release $tag" --notes "Automated release for version $tag"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions WinCertInstaller/Configuration/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class AppSettings
/// <summary>
/// The URL to the ZIP file containing ITI (ICP-Brasil) certificates.
/// </summary>
public string ITICertUrl { get; set; } = string.Empty;
public string ITICertUrl { get; set; } = "http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip";

/// <summary>
/// The URL to the P7B (PKCS #7) file containing MPF certificates.
/// </summary>
public string MPFCertUrl { get; set; } = string.Empty;
public string MPFCertUrl { get; set; } = "http://repositorio.acinterna.mpf.mp.br/ejbca/ra/downloads/ACIMPF-cadeia-completa.p7b";
}
}
10 changes: 10 additions & 0 deletions WinCertInstaller/Configuration/AppSettingsJsonContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
using WinCertInstaller.Configuration;

namespace WinCertInstaller.Configuration
{
[JsonSerializable(typeof(AppSettings))]
internal partial class AppSettingsJsonContext : JsonSerializerContext
{
}
}
25 changes: 7 additions & 18 deletions WinCertInstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,19 @@ private static AppSettings LoadSettings()
try
{
string json = File.ReadAllText(configPath);
if (string.IsNullOrWhiteSpace(json)) return new AppSettings();

using var doc = JsonDocument.Parse(json);
var root = doc.RootElement;

var settings = new AppSettings();

// Try to get the "CertificateSources" property if it exists (nested structure support)
if (root.TryGetProperty("CertificateSources", out var sources))
{
if (sources.TryGetProperty("ITICertUrl", out var itiUrl))
settings.ITICertUrl = itiUrl.GetString() ?? string.Empty;

if (sources.TryGetProperty("MPFCertUrl", out var mpfUrl))
settings.MPFCertUrl = mpfUrl.GetString() ?? string.Empty;
}
else
{
// Fallback to root level if not nested
if (root.TryGetProperty("ITICertUrl", out var itiUrl))
settings.ITICertUrl = itiUrl.GetString() ?? string.Empty;

if (root.TryGetProperty("MPFCertUrl", out var mpfUrl))
settings.MPFCertUrl = mpfUrl.GetString() ?? string.Empty;
return JsonSerializer.Deserialize(sources.GetRawText(), AppSettingsJsonContext.Default.AppSettings) ?? new AppSettings();
}

return settings;

// Try to deserialize from the root (flat structure support)
return JsonSerializer.Deserialize(json, AppSettingsJsonContext.Default.AppSettings) ?? new AppSettings();
}
catch
{
Expand Down
12 changes: 5 additions & 7 deletions WinCertInstaller/WinCertInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
<RootNamespace>WinCertInstaller</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ApplicationManifest>app.manifest</ApplicationManifest>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<PublishAot>true</PublishAot>
<IsAotCompatible>true</IsAotCompatible>
<InvariantGlobalization>false</InvariantGlobalization>
<StackTraceSupport>true</StackTraceSupport>
<OptimizationPreference>Size</OptimizationPreference>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.5" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" CopyToOutputDirectory="Never" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
13 changes: 0 additions & 13 deletions WinCertInstaller/appsettings.json

This file was deleted.

13 changes: 0 additions & 13 deletions publish_optimized/appsettings.json

This file was deleted.