moduleData.CertificateStore(CertificateStore,makeCertificateStore-- * Queries,findCertificate,listCertificates)whereimportData.List(foldl')importData.MonoidimportData.Certificate.X509importqualifiedData.MapasMimportControl.Monad(mplus)-- | A Collection of certificate or store of certificates.dataCertificateStore=CertificateStore(M.MapDistinguishedNameX509)|CertificateStores[CertificateStore]instanceMonoidCertificateStorewheremempty=CertificateStoreM.emptymappends1@(CertificateStore_)s2@(CertificateStore_)=CertificateStores[s1,s2]mappend(CertificateStoresl)s2@(CertificateStore_)=CertificateStores(l++[s2])mappends1@(CertificateStore_)(CertificateStoresl)=CertificateStores([s1]++l)mappend(CertificateStoresl1)(CertificateStoresl2)=CertificateStores(l1++l2)-- | Create a certificate store out of a list of X509 certificatemakeCertificateStore::[X509]->CertificateStoremakeCertificateStore=CertificateStore.foldl'accumulateM.emptywhereaccumulatemx509=M.insert(certSubjectDN$x509Certx509)x509m-- | Find a certificate using the subject distinguished namefindCertificate::DistinguishedName->CertificateStore->MaybeX509findCertificatednstore=lookupInstorewherelookupIn(CertificateStorem)=M.lookupdnmlookupIn(CertificateStoresl)=foldlmplusNothing$maplookupInl-- | List all certificates in a storelistCertificates::CertificateStore->[X509]listCertificates(CertificateStorestore)=mapsnd$M.toListstorelistCertificates(CertificateStoresl)=concatMaplistCertificatesl