Skip to content

Commit 6465f6b

Browse files
corylanouclaude
andauthored
Reject age encryption configuration until support is restored (#791)
Co-authored-by: Claude <[email protected]>
1 parent f236f50 commit 6465f6b

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

cmd/litestream/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ func NewReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *litestream.Re
567567
return nil, fmt.Errorf("replica path cannot be a url, please use the 'url' field instead: %s", c.Path)
568568
}
569569

570+
// Reject age encryption configuration as it's currently non-functional.
571+
// Age encryption support was removed during the LTX storage layer refactor
572+
// and has not been reimplemented. Accepting this config would silently
573+
// write plaintext data to remote storage instead of encrypted data.
574+
// See: https://github.com/benbjohnson/litestream/issues/790
575+
if len(c.Age.Identities) > 0 || len(c.Age.Recipients) > 0 {
576+
return nil, fmt.Errorf("age encryption is not currently supported, if you need encryption please revert back to Litestream v0.3.x")
577+
}
578+
570579
// Build replica.
571580
r := litestream.NewReplica(db)
572581
if v := c.SyncInterval; v != nil {

cmd/litestream/main_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,77 @@ func TestNewGSReplicaFromConfig(t *testing.T) {
217217
}
218218
}
219219

220+
// TestNewReplicaFromConfig_AgeEncryption verifies that age encryption configuration is rejected.
221+
// Age encryption is currently non-functional and would silently write plaintext data.
222+
// See: https://github.com/benbjohnson/litestream/issues/790
223+
func TestNewReplicaFromConfig_AgeEncryption(t *testing.T) {
224+
t.Run("RejectIdentities", func(t *testing.T) {
225+
config := &main.ReplicaConfig{
226+
URL: "s3://foo/bar",
227+
}
228+
config.Age.Identities = []string{"AGE-SECRET-KEY-1EXAMPLE"}
229+
230+
_, err := main.NewReplicaFromConfig(config, nil)
231+
if err == nil {
232+
t.Fatal("expected error when age identities are configured")
233+
}
234+
if !strings.Contains(err.Error(), "age encryption is not currently supported") {
235+
t.Errorf("expected age encryption error, got: %v", err)
236+
}
237+
if !strings.Contains(err.Error(), "revert back to Litestream v0.3.x") {
238+
t.Errorf("expected error to reference v0.3.x, got: %v", err)
239+
}
240+
})
241+
242+
t.Run("RejectRecipients", func(t *testing.T) {
243+
config := &main.ReplicaConfig{
244+
URL: "s3://foo/bar",
245+
}
246+
config.Age.Recipients = []string{"age1example"}
247+
248+
_, err := main.NewReplicaFromConfig(config, nil)
249+
if err == nil {
250+
t.Fatal("expected error when age recipients are configured")
251+
}
252+
if !strings.Contains(err.Error(), "age encryption is not currently supported") {
253+
t.Errorf("expected age encryption error, got: %v", err)
254+
}
255+
if !strings.Contains(err.Error(), "revert back to Litestream v0.3.x") {
256+
t.Errorf("expected error to reference v0.3.x, got: %v", err)
257+
}
258+
})
259+
260+
t.Run("RejectBoth", func(t *testing.T) {
261+
config := &main.ReplicaConfig{
262+
URL: "s3://foo/bar",
263+
}
264+
config.Age.Identities = []string{"AGE-SECRET-KEY-1EXAMPLE"}
265+
config.Age.Recipients = []string{"age1example"}
266+
267+
_, err := main.NewReplicaFromConfig(config, nil)
268+
if err == nil {
269+
t.Fatal("expected error when both age identities and recipients are configured")
270+
}
271+
if !strings.Contains(err.Error(), "age encryption is not currently supported") {
272+
t.Errorf("expected age encryption error, got: %v", err)
273+
}
274+
if !strings.Contains(err.Error(), "revert back to Litestream v0.3.x") {
275+
t.Errorf("expected error to reference v0.3.x, got: %v", err)
276+
}
277+
})
278+
279+
t.Run("AllowEmpty", func(t *testing.T) {
280+
config := &main.ReplicaConfig{
281+
URL: "s3://foo/bar",
282+
}
283+
284+
_, err := main.NewReplicaFromConfig(config, nil)
285+
if err != nil {
286+
t.Fatalf("unexpected error when age configuration is not present: %v", err)
287+
}
288+
})
289+
}
290+
220291
// TestConfig_Validate_SnapshotIntervals tests validation of snapshot intervals
221292
func TestConfig_Validate_SnapshotIntervals(t *testing.T) {
222293
t.Run("ValidInterval", func(t *testing.T) {

0 commit comments

Comments
 (0)