/// <summary> /// Get certificate chain of trust. /// </summary> /// <param name="store"></param> /// <param name="serialNumber">serial number of the /// certificate </param> /// <param name="ct"></param> /// <returns></returns> public static async Task <CertificateCollection> ListCertificateChainAsync( this ICertificateStore store, byte[] serialNumber, CancellationToken ct = default) { var cert = await store.GetCertificateAsync(serialNumber, ct); return(await store.ListCertificateChainAsync(cert, ct)); }
/// <summary> /// Get certificate chain of trust. /// </summary> /// <param name="store"></param> /// <param name="certificate">certificate</param> /// <param name="ct"></param> /// <returns></returns> public static async Task <IEnumerable <Certificate> > ListCompleteCertificateChainAsync( this ICertificateStore store, Certificate certificate, CancellationToken ct = default) { var certificates = new List <Certificate>(); var chain = await store.ListCertificateChainAsync(certificate, ct); if (chain != null) { certificates.AddRange(chain.Certificates); } while (chain?.ContinuationToken != null) { chain = await store.ListCertificatesAsync( chain.ContinuationToken, null, ct); certificates.AddRange(chain.Certificates); } return(certificates); }