static async Task <Certificate> GetCertificateAsync(Plugin.Type type, Client client) { if (!CertificateCache.TryGetValue(type, out var ret)) { using var resp = await client.SendAsync("GET", $"https://fnbot.shop/api/plugincert?t={type:X}"); ret = new Certificate(resp.Stream); CertificateCache[type] = ret; switch (await ret.VerifyAsync(await GetCertificateAsync((Plugin.Type) 0xFF, client), client)) { case Certificate.VerifyError.INVALID: throw new SecurityException("Parent certificate is invalid"); case Certificate.VerifyError.EXPIRED: throw new SecurityException("Parent certificate is expired"); case Certificate.VerifyError.REVOKED: throw new SecurityException("Parent certificate is revoked"); } } return(ret); }
// Helper Methods static Type GetPluginType(Plugin.Type type) => type switch {