func (cont *CertificateController) AddCertToOrgIndex(cert *x509.Certificate, tags string) error { logger.Debug("adding certificate to org index") logger.Tracef("received certificate with id '%s' and tags '%s'", cert.Id(), tags) orgIndex, err := cont.env.controllers.org.GetIndex() if err != nil { return err } err = orgIndex.AddCert(cert.Data.Body.Name, cert.Data.Body.Id) if err != nil { return err } err = orgIndex.AddCertTags(cert.Data.Body.Id, ParseTags(tags)) if err != nil { return err } err = cont.env.controllers.org.SaveIndex(orgIndex) if err != nil { return err } logger.Trace("returning nil error") return nil }
func (cont *CertificateController) SaveCert(cert *x509.Certificate) error { logger.Debug("saving certificate") logger.Tracef("received certificate with id '%s'", cert.Id()) logger.Debug("encrypting cert for org") certContainer, err := cont.env.controllers.org.org.EncryptThenSignString(cert.Dump(), nil) if err != nil { return err } logger.Debug("saving encrypted cert") err = cont.env.api.SendPrivate(cont.env.controllers.org.org.Data.Body.Id, cert.Data.Body.Id, certContainer.Dump()) if err != nil { return err } logger.Trace("returning nil error") return nil }