Rotate signing keys
This guide replaces your signing key without breaking installed copies of your application. At the end, new builds embed the new public key, older builds keep working, and you can delete the old key when no copy uses it.
When to rotate
A signing key does not expire, and Seatify does not require a rotation. Rotate when your security policy requires a regular change of keys, or when you want to stop trusting a key.
A rotation alone does not stop a key. A retired key still signs for every copy of your application that names it. Only deletion stops the key. See Active and retired keys.
Before you start
- Your application verifies signed responses with an embedded public key. See Verify signed responses.
- Your application keeps its embedded keys in a map from key ID to public key. The examples in Verify the response and Verify the file do this.
- Your application names its key in the
Seatify-Signing-Keyheader on every request to the License API and the Distribution API. That includes license file check-outs. See Key selection.
Seatify-Signing-Key header, Seatify signs its requests with the active key. After a rotation, that copy has no key for the new key ID, and it rejects every answer. Ship a build that sends the header before you rotate.The examples call https://license.seatify.dev. In curl, the keys are the variables $SEATIFY_PUBLISHABLE_KEY and $SEATIFY_SIGNING_KEY_ID. In the other languages, they are variables of your application.
Steps
Rotate the key
Rotate the signing key in the dashboard. Seatify creates a new active key, and the old key becomes retired. Copy the key ID of the new key and its public key in Base64.
The rotation does not affect installed copies. They name the old key, and the retired key still signs for them. A request that names no key is signed with the new key. New files that you publish are signed with the new key.
Embed the new key
Add the new key to the map of embedded keys. Keep the old key in the map.
Your application still needs the old key after the update:
- A license file that the device stored before the update is signed with the old key. It stays valid until it expires.
- A file of a release that you published before the rotation is signed with the old key until you re-sign it.
Name the new key
Send the key ID of the new key in the Seatify-Signing-Key header. Seatify then signs the answers and new license files of this build with the new key.
curl -i https://license.seatify.dev/v1/ping \
-H "Seatify-Publishable-Key: $SEATIFY_PUBLISHABLE_KEY" \
-H "Seatify-Signing-Key: $SEATIFY_SIGNING_KEY_ID" \
-H "Seatify-Nonce: $(uuidgen)"The keyid in the Seatify-Signature header of the answer is the new key ID:
Seatify-Signature: keyid="<new key id>", algorithm="ed25519", signature="<signature in Base64>", headers="(request-target) host date digest seatify-nonce"Ship the new build
Publish the new build as a release. Installed copies update over time. Until then, they keep working with the old key.
An older build that checks for this update finds no embedded key for the signature of the new file. See Updates across a rotation.
Wait for old copies
The dashboard shows the last used time of each key. Seatify updates this time at most once an hour. The time includes signed answers and license files, also the files that you download in the dashboard.
A copy that runs rarely can name the old key long after the last use. Wait as long as your users take to update.
Re-sign the files
Re-sign in the dashboard each file that the old key still signs. Seatify signs the file again with the active key. The Distribution API shows the key ID of each file in signing_key_id.
Seatify refuses to delete a key that still signs files.
Delete the old key
Delete the retired key in the dashboard. Deletion is permanent. See After deletion.
This step is optional. A retired key can stay as long as you need it.
Updates across a rotation
Seatify signs every new file with the active key. After a rotation, an older build checks an update that the new key signed. The older build does not embed the new key, so it cannot check the signature of the file.
The older build can still trust the SHA-256 of the file. The release data comes in an answer that the old key signed, because the older build names the old key. The SHA-256 in this answer is as trustworthy as the signature.
Check a downloaded file in this order:
- Verify the answer that lists the file. See Verify signed responses.
- Compute the SHA-256 of the file. It must equal
sha256from the verified answer. - If an embedded key has the key ID in
signing_key_id, checksignaturewith this key. See Verifying files. - If no embedded key has this key ID, the SHA-256 check is enough.
Never trust a SHA-256 from an answer that your application did not verify.
Devices with no internet
A device with no internet gets its license file from you. When you download the file in the dashboard, choose the key that the build of the customer embeds. For a build from before the rotation, choose the retired key. See Devices with no internet.
Before you delete the retired key, check that no customer with no internet still runs a build that embeds only this key.
After deletion
- Every request that names the deleted key fails with the status 400 and the message “The signing key is not known.” Seatify refuses the request before it makes any change.
- Seatify signs no new license files with the deleted key.
- A license file that the deleted key signed still verifies on the device until the file expires. The device checks the file with its embedded key.
- The active key cannot be deleted. Rotate first.