2022-06-20 18:20:17 -07:00
|
|
|
package server
|
2022-06-03 12:13:31 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
|
|
|
|
"github.com/hashicorp/nodeenrollment"
|
|
|
|
|
"github.com/hashicorp/nodeenrollment/rotation"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// RotateRoots is a domain service function that initiates a rotation of root certificates
|
|
|
|
|
// via a call to the nodenenrollment RotateRootCertificates function
|
|
|
|
|
// Accepts the nodeenrollment option, WithCertificateLifetime(time.Duration) to specify the lifetime
|
|
|
|
|
// of the generated cert(s)
|
|
|
|
|
func RotateRoots(ctx context.Context, workerAuthRepo *WorkerAuthRepositoryStorage, opt ...nodeenrollment.Option) error {
|
2022-06-20 18:20:17 -07:00
|
|
|
const op = "server.RotateRoots"
|
2022-06-03 12:13:31 -04:00
|
|
|
if workerAuthRepo == nil {
|
|
|
|
|
return errors.New(ctx, errors.InvalidParameter, op, "missing workerAuthRepo")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := rotation.RotateRootCertificates(ctx, workerAuthRepo, opt...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.Wrap(ctx, err, op)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|