cacert-gosigner/pkg/hsm/setup.go

43 lines
828 B
Go
Raw Normal View History

package hsm
import (
"context"
"log"
)
func EnsureCAKeysAndCertificates(ctx context.Context) error {
var label string
conf := GetSignerConfig(ctx)
for _, label := range conf.RootCAs() {
crt, err := GetRootCACertificate(ctx, label)
if err != nil {
return err
}
log.Printf("got root CA certificate:\n Subject %s\n Issuer %s\n Valid from %s until %s\n Serial %s",
crt.Subject,
crt.Issuer,
crt.NotBefore,
crt.NotAfter,
crt.SerialNumber)
}
for _, label = range conf.IntermediaryCAs() {
crt, err := GetIntermediaryCACertificate(ctx, label)
if err != nil {
return err
}
log.Printf("got intermediary CA certificate:\n Subject %s\n Issuer %s\n Valid from %s until %s\n Serial %s",
crt.Subject,
crt.Issuer,
crt.NotBefore,
crt.NotAfter,
crt.SerialNumber)
}
return nil
}