package validate import ( "errors" "io/fs" "os" "jarl/internal/model" "jarl/internal/namedconf" ) // checkTLSFiles checks that the files a top-level tls statement names // exist: named fails to load the whole configuration otherwise. (Files // jarld can't look at are left to named.) func (c *checker) checkTLSFiles() { for _, o := range c.s.ScopedOptions(model.ScopeTopLevel, 0) { if o.Name != "tls" { continue } stmt, err := namedconf.ParseOptionValue("tls", o.Value) if err != nil || stmt.FirstBlock() == nil { continue } for _, s := range stmt.FirstBlock().Stmts { switch s.Keyword() { case "cert-file", "key-file", "ca-file", "dhparam-file": path := s.Arg(0) if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) { c.errf("tls_file_missing", "option", o.ID, "tls %s: %s %s doesn't exist, and named won't load its configuration without it (a certificate Jarl obtains is written once it has been obtained: jarl cert list)", stmt.Arg(0), s.Keyword(), path) } } } } }