fixed trimming bug in get_cert, its 75mb now

This commit is contained in:
Kim 2023-03-30 08:30:40 +02:00
parent eb03329441
commit 46db92fee5
3 changed files with 25 additions and 12 deletions

View File

@ -1,17 +1,17 @@
using System.Diagnostics.CodeAnalysis;
#pragma warning disable CS8618
namespace InnovEnergy.App.OpenVpnCertificatesServer;
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
internal class AccToken
{
public String token { get; init; }
public String bearer { get; init; }
public String bearer { get; init; } = "";
public UInt64 idUser { get; init; }
public String verification_mode { get; init; }
public String idAccessToken { get; init; }
public Boolean verification_sent { get; init; }
public Boolean success { get; init; }
public String verification_mode { get; init; } = "password";
public Boolean verification_sent { get; init; } = false;
public Boolean success { get; init; } = false;
public String token { get; init; } = "";
public String idAccessToken { get; init; } = "";
}

View File

@ -19,4 +19,8 @@
</None>
</ItemGroup>
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -36,10 +36,11 @@ public static class Program
private const String CertsDir = VpnDir + "/certs";
private const String Endpoint = "http://localhost:4000/";
private static AccToken ReadAccessToken()
private static AccToken? ReadAccessToken()
{
var content = File.ReadAllText("./token.json");
return JsonSerializer.Deserialize<AccToken>(content)!;
return JsonSerializer.Deserialize<AccToken>(content);
}
@ -146,9 +147,14 @@ public static class Program
//var installationName = await LookupInstallationNameByUniqueId(ccdName);
var token = ReadAccessToken();
using var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations();
var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations();
var installationName = installations
.Where(i => i.UniqueId == uniqueId)
.Select(i => i.Name)
@ -163,7 +169,9 @@ public static class Program
{
Console.WriteLine($"looking up {ccdName} on VRM");
var token = ReadAccessToken();
using var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations();
foreach (var installation in installations)
@ -176,6 +184,7 @@ public static class Program
return (ccdName, installation.Name);
}
Console.WriteLine($"not found");
return null;
}