/// <inheritdoc/> public async Task <X509CertificateListModel> ListTrustedCertificatesAsync( string entityId, string nextPageLink, int?maxPageSize, CancellationToken ct) { // Get all var trusted = await _repo.ListAsync(entityId, TrustDirectionType.Trusting, nextPageLink, maxPageSize, ct); var result = new X509CertificateListModel { NextPageLink = trusted.NextPageLink, Certificates = new List <X509CertificateModel>() }; // Foreach entity, resolve certificate chains foreach (var relationship in trusted.Relationships) { // Get latest certificate from store - it has the id of the entity var trustedCert = await _certificates.FindLatestCertificateAsync( relationship.TrustedId, ct); if (trustedCert == null) { continue; } result.Certificates.Add(trustedCert.ToServiceModel()); } return(result); }
/// <summary> /// Create collection /// </summary> /// <param name="model"></param> public X509CertificateListApiModel(X509CertificateListModel model) { NextPageLink = model.NextPageLink; Certificates = model?.Certificates? .Select(c => new X509CertificateApiModel(c)) .ToList(); }
/// <summary> /// Create collection /// </summary> /// <param name="model"></param> public static X509CertificateListApiModel ToApiModel( this X509CertificateListModel model) { if (model == null) { return(null); } return(new X509CertificateListApiModel { Certificates = model.Certificates? .Select(c => c.ToApiModel()) .ToList(), NextPageLink = model.NextPageLink }); }