fa35bfc106
---ci--- project: orca phase: 2 milestone: v0.3 status: complete requirements: covered: [REQ-032] partial: [] ---/ci--- P02: orca doctor network + db full implementation. - DB(): PRAGMA integrity_check + MigrationVersion (PASS/WARN/FAIL) - Network(): mTLS /healthz probe per peer, 3s timeout, zero peers → WARN - certpaths.DBPath() relocation (D-039, breaks import cycle) - store.MigrationVersion() public API - Deleted NetworkStub/DBStub (D-040) - 7 doctor tests + 1 MigrationVersion test, all pass under -race - 4-layer verification passed
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
// Package certpaths centralizes the on-disk locations of the CA and
|
|
// server cert/key files. The CLI layer, the security layer, and the
|
|
// doctor layer all need to agree on these paths, so they're factored
|
|
// into their own package to avoid import cycles (cli <-> doctor).
|
|
package certpaths
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
const (
|
|
defaultCADir = ".orca"
|
|
caCertFilename = "ca.crt"
|
|
caKeyFilename = "ca.key"
|
|
)
|
|
|
|
// Dir returns the directory the local CA lives in. Honors $ORCA_HOME
|
|
// for testability; otherwise defaults to ~/.orca.
|
|
func Dir() string {
|
|
if p := os.Getenv("ORCA_HOME"); p != "" {
|
|
return p
|
|
}
|
|
home, _ := os.UserHomeDir()
|
|
return filepath.Join(home, defaultCADir)
|
|
}
|
|
|
|
// CACertPath returns the path to ca.crt.
|
|
func CACertPath() string { return filepath.Join(Dir(), caCertFilename) }
|
|
|
|
// CAKeyPath returns the path to ca.key.
|
|
func CAKeyPath() string { return filepath.Join(Dir(), caKeyFilename) }
|
|
|
|
// ServerCertPath returns the path to server.crt.
|
|
func ServerCertPath() string { return filepath.Join(Dir(), "server.crt") }
|
|
|
|
// ServerKeyPath returns the path to server.key.
|
|
func ServerKeyPath() string { return filepath.Join(Dir(), "server.key") }
|
|
|
|
// DBPath returns the path to the orca SQLite database. Honors $ORCA_DB
|
|
// for testability and explicit override; otherwise defaults to
|
|
// ~/.orca/orca.db under the same Dir() as the cert files.
|
|
func DBPath() string {
|
|
if p := os.Getenv("ORCA_DB"); p != "" {
|
|
return p
|
|
}
|
|
return filepath.Join(Dir(), "orca.db")
|
|
}
|