From ad4dbd6764ef807f952b7490a988a3c3f4376e19 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Thu, 5 Aug 2021 12:58:54 -0700 Subject: [PATCH] Write all files on save. --- pki/pki.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pki/pki.go b/pki/pki.go index 72350cd6..87e4842e 100644 --- a/pki/pki.go +++ b/pki/pki.go @@ -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 // authority configuration. 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() // Generate and write ca.json