Repository navigation
Clean up the Linux config encryption key change - #1352
Merged
LukeButters merged 12 commits intoNov 17, 2026
Merged
LukeButters merged 12 commits into
LukeButters merged 12 commits into
Conversation
…achine key source
…on key is unreadable
LukeButters
marked this pull request as ready for review
November 17, 2026 03:38
LukeButters
merged commit Nov 17, 2026
bb13d96
into
luke/lev-1171-config-encryption-key
20 of 25 checks passed
This was referenced Nov 17, 2026
LukeButters
added a commit
that referenced
this pull request
Nov 23, 2026
* Split the per-instance configuration encryption key from the legacy machine key source * Do not fall back to legacy encryption when the configuration encryption key is unreadable * Remove duplicated legacy key and decryption error handling * Require callers to supply the encryptor when creating an XmlFileKeyValueStore * Reduce ITentacleConfigurationUpgrade to PrepareKey and Run, both throwing * Move Unix P/Invoke into UnixFile * Simplify AtomicCreateFileWithUserReadWriteAccessOnly to one implementation * Resolve the instance's key path in Tentacle Manager instead of passing null * Rename WriteUserReadWriteOnly to CreateOwnerOnlyFile * Read the link error before another call can overwrite it * Move the upgrade's warn-and-continue handling into TentacleConfigurationUpgrade * Rename the configuration upgrade's Run to Upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Structural cleanup on top of #1348. No intended change to how legacy ciphertext or legacy key files are handled.
Changes (one commit each)
ConfigurationEncryptionKeyout ofLinuxGeneratedMachineKey. The legacy source is read-only again;ICryptoKeyNixSource.TryLoadand theNoConfigurationEncryptionKeynull object are gone. The new key file now holds onlybase64(key)(no unused IV).Encryptuses the legacy scheme only when the key file does not exist; an unreadable or corrupt key throws.TryEachLegacyKeyhelper inLinuxMachineKeyEncryptor; oneDecrypt(name, value)helper inFlatDictionaryKeyValueStoreinstead of thedecryptingflag.XmlFileKeyValueStoretakes a requiredIMachineKeyEncryptorinstead of optionalencryptor+keyFilePath.ITentacleConfigurationUpgradeis two throwing methods (PrepareKey,Run).ServiceCommandandRunAgentCommanddo their own catch-and-warn.UnixFile(now public).AtomicCreateFileWithUserReadWriteAccessOnlyis one implementation. On Unix it publishes withlink(2)only; the racyFile.Movefallback is removed.New command:
replace-certificateRecovers a Tentacle whose certificate is lost, for example because its configuration encryption key was deleted and there is no backup. It generates a new key and certificate, then updates only the endpoint thumbprint on the existing deployment target or worker in Octopus. Environments, roles, tenants and policy are left alone, unlike
register-with --force, which replaces them with whatever is passed. It also re-trusts the server and, for polling Tentacles, keeps the existing subscription ID.--id Machines-123/--id Workers-45instead of--name. A name is searched in both targets and workers and fails if it matches both.--spacefor a non-default space.--server-comms-address/--server-comms-portfor polling Tentacles (default port 10943).The missing/corrupt key error message now points at this command.
Tested end to end against a local Octopus Server with a listening Tentacle: deleted the key file, ran the command, and the same machine (same ID, roles, environments) got the new thumbprint and passed a health check.
Behaviour changes to be aware of
base64(key)rather thanbase64(key).base64(iv). A key file created by a build of Stop deriving Linux Tentacle's config encryption key from /etc/machine-id #1348 will be reported as corrupt.Encryptinstead of quietly writing legacy ciphertext.linkfails and the target does not exist (e.g. a file system without hard links), key creation now throws instead of falling back toFile.Move.Not verified
replace-certificatewas not tested end to end with polling Tentacles, workers, websockets or proxies (unit tests cover a polling worker). It saves the new certificate before updating Octopus, so a failed update leaves them out of sync until it is re-run.Octopus.Manager.Tentacleand thenet10.0-windowstarget were not built; Windows runtime paths (File.Movepublish) were not run.Only the Configuration/Commands/FileSystem unit tests (302 passed) and the Linux Docker run of the Configuration tests (159 passed as root and as non-root) were run. Integration tests were built, not run.
The catch-and-warn paths in
ServiceCommandandRunAgentCommandhave no test.UpgradeConfigurationEncryptionCommandstill re-checks the upgrade's preconditions; removing that did not come out simpler.