forked from TrueCloudLab/certificates
Validate provisioner configuration before storing in DB
This commit is contained in:
parent
dedd136407
commit
6030f8bc2e
1 changed files with 10 additions and 6 deletions
|
@ -133,9 +133,18 @@ func (a *Authority) StoreProvisioner(ctx context.Context, prov *linkedca.Provisi
|
|||
"provisioner with token ID %s already exists", certProv.GetIDForToken())
|
||||
}
|
||||
|
||||
provisionerConfig, err := a.generateProvisionerConfig(ctx)
|
||||
if err != nil {
|
||||
return admin.WrapErrorISE(err, "error generating provisioner config")
|
||||
}
|
||||
|
||||
if err := certProv.Init(*provisionerConfig); err != nil {
|
||||
return admin.WrapError(admin.ErrorBadRequestType, err, "error validating configuration for provisioner %s", prov.Name)
|
||||
}
|
||||
|
||||
// Store to database -- this will set the ID.
|
||||
if err := a.adminDB.CreateProvisioner(ctx, prov); err != nil {
|
||||
return admin.WrapErrorISE(err, "error creating admin")
|
||||
return admin.WrapErrorISE(err, "error creating provisioner")
|
||||
}
|
||||
|
||||
// We need a new conversion that has the newly set ID.
|
||||
|
@ -145,11 +154,6 @@ func (a *Authority) StoreProvisioner(ctx context.Context, prov *linkedca.Provisi
|
|||
"error converting to certificates provisioner from linkedca provisioner")
|
||||
}
|
||||
|
||||
provisionerConfig, err := a.generateProvisionerConfig(ctx)
|
||||
if err != nil {
|
||||
return admin.WrapErrorISE(err, "error generating provisioner config")
|
||||
}
|
||||
|
||||
if err := certProv.Init(*provisionerConfig); err != nil {
|
||||
return admin.WrapErrorISE(err, "error initializing provisioner %s", prov.Name)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue