func (s *fdbStore) SaveAccount(a *Account) error { coll := s.db.Collection("accounts/" + a.ID()) w, err := coll.Create("privkey") if err != nil { return err } defer w.CloseAbort() err = acmeutils.SavePrivateKey(w, a.PrivateKey) if err != nil { return err } w.Close() for _, auth := range a.Authorizations { c := coll.Collection("authorizations/" + auth.Name) err := fdb.WriteBytes(c, "expiry", []byte(auth.Expires.Format(time.RFC3339))) if err != nil { return err } err = fdb.WriteBytes(c, "url", []byte(auth.URL)) if err != nil { return err } } return nil }
// Saves a key as a file named "privkey" inside the given collection. func (s *fdbStore) saveKey(c *fdb.Collection, privateKey crypto.PrivateKey) error { f, err := c.Create("privkey") if err != nil { return err } defer f.CloseAbort() err = acmeutils.SavePrivateKey(f, privateKey) if err != nil { return err } return f.Close() }
func generateHookPEM(info *responder.TLSSNIChallengeInfo) (string, error) { b := bytes.Buffer{} err := acmeutils.SaveCertificates(&b, info.Certificate) if err != nil { return "", err } err = acmeutils.SavePrivateKey(&b, info.Key) if err != nil { return "", err } return b.String(), nil }