28 Commits

Author SHA1 Message Date
92fb052594
more fixes before final part
All checks were successful
Unit Tests / unit-tests (pull_request) Successful in 9m58s
Integration Tests / integration-tests (pull_request) Successful in 9m58s
2025-05-18 11:35:22 -04:00
8f90c1b16d
fix: update TLS configuration to use leader hostname and custom dialer 2025-05-18 10:51:06 -04:00
641a2f09d3
fix: add insecure TLS verification for initial cluster join 2025-05-18 10:46:05 -04:00
0e50eaa407
fix: correct error handling in JoinCluster function to return proper response 2025-05-18 10:46:01 -04:00
ee9d14be05
fix: modify TLS configuration to handle hostname verification for cluster nodes 2025-05-17 13:50:49 -04:00
b777739509
test: remove unused testify assert import 2025-05-17 13:50:47 -04:00
3408e7801e
feat: Implement agent heartbeat with mTLS and node status tracking 2025-05-17 13:32:05 -04:00
e4a19a6bb8
Based on the changes, I'll generate a concise commit message that captures the essence of the modifications:
feat: add node registration verification and idle loop for joined nodes
2025-05-17 13:19:16 -04:00
bf80b65873
feat: Implement CSR signing and node registration handler for agent join 2025-05-17 13:05:21 -04:00
f1f2b8f9ef
fix: update TestServerWithMTLS to match Phase 2 TLS configuration 2025-05-17 12:50:16 -04:00
ce6f2ce29d
Minor fixes 2025-05-17 12:48:37 -04:00
b33127bd34
fix: disable client cert verification for Phase 2 development 2025-05-17 12:38:20 -04:00
c07f389996
feat: modify TLS config to allow initial node join without client certificate 2025-05-17 12:32:26 -04:00
4f7c2d6a66
I noticed a duplicate function in the internal/pki/ca.go file. I'll help you clean it up. Here's the corrected version:
```go
package pki

import (
	// other imports
	"path/filepath"
)

const (
	// Default key size for RSA keys
	DefaultRSAKeySize = 2048
	// Default CA certificate validity period
	DefaultCAValidityDays = 3650 // ~10 years
	// Default certificate validity period
	DefaultCertValidityDays = 365 // 1 year
	// Default PKI directory
	DefaultPKIDir = "/var/lib/kat/pki"
)

// GetPKIPathFromClusterConfig determines the PKI directory from the cluster configuration.
// If backupPath is provided, it uses the parent directory of backupPath.
// Otherwise, it uses the default PKI directory.
func GetPKIPathFromClusterConfig(backupPath string) string {
	if backupPath == "" {
		return DefaultPKIDir
	}

	// Use the parent directory of backupPath
	return filepath.Dir(backupPath) + "/pki"
}

// generateSerialNumber creates a random serial number for certificates
func generateSerialNumber() (*big.Int, error) {
	serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) // 128 bits
	return rand.Int(rand.Reader, serialNumberLimit)
}

// Rest of the existing code...
```

The changes:
1. Removed the duplicate `GetPKIPathFromClusterConfig` function
2. Kept the single implementation that checks for an empty backup path
3. Maintained the default PKI directory as `/var/lib/kat/pki`

This should resolve the duplicate function issue while maintaining the desired functionality.

Would you like me to generate a commit message for this change?
2025-05-17 12:18:42 -04:00
af6a584628
feat: add request logging middleware and improve server logging 2025-05-17 12:18:32 -04:00
9e63518308
feat: Implement basic API server with mTLS for leader join endpoint 2025-05-16 22:18:58 -04:00
800e4f72f2
Run gofmt 2025-05-16 22:13:42 -04:00
2f6d3c9bb2
Use local paths when possible, some AI cleanup 2025-05-16 21:20:39 -04:00
4f6365d453
fix: handle CSR file path and raw PEM data in SignCertificateRequest 2025-05-16 21:17:23 -04:00
47f9b69876
fix: add DNS names to CSR and improve certificate generation 2025-05-16 21:15:43 -04:00
787262c8a0
refactor: change default PKI directory to user home directory 2025-05-16 21:15:40 -04:00
52d7af083e
refactor: remove duplicate certificate request functions from certs.go 2025-05-16 21:01:34 -04:00
bcff04db12
Based on the implementation, I'll generate a concise commit message that captures the essence of the changes:
feat: implement PKI initialization and leader mTLS certificate generation
2025-05-16 20:59:01 -04:00
7adabe8630
feat: implement internal PKI utilities for CA and certificate management 2025-05-16 20:47:57 -04:00
58bdca5703 Implement Phase 1 of KAT (#1)
All checks were successful
Unit Tests / unit-tests (push) Successful in 9m54s
Integration Tests / integration-tests (push) Successful in 10m0s
**Phase 1: State Management & Leader Election**
*   **Goal**: A functional embedded etcd and leader election mechanism.
*   **Tasks**:
    1.  Implement the `StateStore` interface (RFC 5.1) with an etcd backend (`internal/store/etcd.go`).
    2.  Integrate embedded etcd server into `kat-agent` (RFC 2.2, 5.2), configurable via `cluster.kat` parameters.
    3.  Implement leader election using `go.etcd.io/etcd/client/v3/concurrency` (RFC 5.3).
    4.  Basic `kat-agent init` functionality:
        *   Parse `cluster.kat`.
        *   Start single-node embedded etcd.
        *   Campaign for and become leader.
        *   Store initial cluster configuration (UID, CIDRs from `cluster.kat`) in etcd.
*   **Milestone**:
    *   A single `kat-agent init --config cluster.kat` process starts, initializes etcd, and logs that it has become the leader.
    *   The cluster configuration from `cluster.kat` can be verified in etcd using an etcd client.
    *   `StateStore` interface methods (`Put`, `Get`, `Delete`, `List`) are testable against the embedded etcd.

Reviewed-on: #1
2025-05-16 20:19:25 -04:00
432a3fdbc4
Fix loading and some tests 2025-05-10 18:54:10 -04:00
1ae06781d6
[Aider] Phase 0 2025-05-10 18:18:58 -04:00
2f0debf608
feat: Add unit tests for cluster config parsing and tarball utility 2025-05-10 17:41:43 -04:00