Write all files on save.

This commit is contained in:
Mariano Cano 2021-08-05 12:58:54 -07:00
parent 50f7a0d0c0
commit ad4dbd6764

View file

@ -832,6 +832,13 @@ func (p *PKI) GenerateConfig(opt ...Option) (*authconfig.Config, error) {
// Save stores the pki on a json file that will be used as the certificate // Save stores the pki on a json file that will be used as the certificate
// authority configuration. // authority configuration.
func (p *PKI) Save(opt ...Option) error { func (p *PKI) Save(opt ...Option) error {
// Write pre-generated files.
for fn, b := range p.Files {
if err := fileutil.WriteFile(fn, b, 0600); err != nil {
return err
}
}
p.tellPKI() p.tellPKI()
// Generate and write ca.json // Generate and write ca.json