Skip to content

Commit 93f1b35

Browse files
committed
[client] treat turning off in-band WRAP as needs-restart instead of silently breaking
1 parent 43b5f14 commit 93f1b35

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

client/patch.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,27 @@ func applyPatch(req *appcontrolpb.PatchConfigRequest) {
208208
mode = req.GetWrapMode()
209209
}
210210
cipherSel, key, resolvedMode, err := resolveWrapConfig(mode, req.GetWrapCipher(), req.GetWrapKeyHex())
211-
if err != nil {
211+
sendKey := next.wrapSendKey
212+
if req.WrapSendKey != nil {
213+
sendKey = req.GetWrapSendKey()
214+
}
215+
switch {
216+
case err != nil:
212217
publishPatchStatus(reqID, "wrap", "failed", err.Error())
213-
} else {
218+
case cur.wrapSendKey && !sendKey && resolvedMode != "off":
219+
// Turning in-band key delivery off while WRAP stays active cannot be done
220+
// live: new streams would negotiate WRAP without sending the key, but the
221+
// server has no matching preset for an auto-generated key (and we cannot
222+
// verify one), so the switch would silently break traffic. Keep the
223+
// previous WRAP and tell the app it needs a restart. next.wrap* already
224+
// holds the current values (copied from cur), so nothing migrates.
225+
publishPatchStatus(reqID, "wrap", "reverted_needs_restart",
226+
"turning off in-band WRAP key can only take effect on the next start")
227+
default:
214228
next.wrapCipher = cipherSel
215229
next.wrapKey = key
216230
next.wrapMode = resolvedMode
217-
if req.WrapSendKey != nil {
218-
next.wrapSendKey = req.GetWrapSendKey()
219-
}
231+
next.wrapSendKey = sendKey
220232
wrapMigrated = true
221233
}
222234
}

0 commit comments

Comments
 (0)