private static string[] ExtractCertificates(string jwt) { string[] certificates = new string[0]; if (!string.IsNullOrEmpty(jwt)) { try { var parsedBody = JoseHelper.ExtractJosePart(jwt, 1); var parsedCertificates = parsedBody["maa-policyCertificates"]["keys"].ToArray(); certificates = parsedCertificates.Select(c => c.ToString()).ToArray(); } catch (Exception) { // Ignore on purpose } } return(certificates); }
private static (string algorithm, string jku) ExtractHeaders(string jwt) { var algorithm = ""; var jku = ""; if (!string.IsNullOrEmpty(jwt)) { try { var parsedHeader = JoseHelper.ExtractJosePart(jwt, 0); algorithm = parsedHeader["alg"].ToString(); jku = parsedHeader["jku"].ToString(); } catch (Exception) { // Ignore on purpose } } return(algorithm, jku); }