Ejemplo n.º 1
0
func (cont *CSRController) AddCSRToOrgIndex(csr *x509.CSR, tags string) error {
	logger.Debug("adding CSR to org index")
	logger.Tracef("received CSR with id '%s' and tags '%s'", csr.Id(), tags)

	orgIndex, err := cont.env.controllers.org.GetIndex()
	if err != nil {
		return err
	}

	err = orgIndex.AddCSR(csr.Data.Body.Name, csr.Data.Body.Id)
	if err != nil {
		return err
	}

	err = orgIndex.AddCSRTags(csr.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
}
Ejemplo n.º 2
0
func (cont *CSRController) SaveCSR(csr *x509.CSR) error {
	logger.Debug("saving CSR")
	logger.Tracef("received CSR with id '%s'", csr.Id)

	logger.Debug("encrypting CSR for org")
	csrContainer, err := cont.env.controllers.org.org.EncryptThenSignString(csr.Dump(), nil)
	if err != nil {
		return err
	}

	logger.Debug("saving encrypted csr")
	err = cont.env.api.SendPrivate(cont.env.controllers.org.org.Data.Body.Id, csr.Data.Body.Id, csrContainer.Dump())
	if err != nil {
		return err
	}

	logger.Trace("returning nil error")
	return nil
}