Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow legacy signature service to start without actorsKeyPairsDir setting #1315

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/middleware/packages/crypto/keys/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ module.exports = {

/** Returns true, if the server has migrated to the new keys service yet, i.e. keys are stored in the user dataset, not on fs. */
async isMigrated() {
// If the `actorsKeyPairsDir` setting is not set, we assume migration has happened or was never needed.
if (!this.settings.actorsKeyPairsDir) {
return true;
}

// Check actorsKeyPairsDir for existing keys.
if (!fs.existsSync(this.settings.actorsKeyPairsDir)) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/middleware/packages/crypto/signature/keypair.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const SignatureService = {
actorsKeyPairsDir: null
},
async created() {
if (!this.settings.actorsKeyPairsDir) {
throw new Error('You must set the actorsKeyPairsDir setting in the signature service');
} else if (!fs.existsSync(this.settings.actorsKeyPairsDir)) {
throw new Error(`The actorsKeyPairsDir (${this.settings.actorsKeyPairsDir}) does not exist! Please create it.`);
if (this.settings.actorsKeyPairsDir && !fs.existsSync(this.settings.actorsKeyPairsDir)) {
throw new Error(
`The \`actorsKeyPairsDir\` is configured for the keys legacy service but the directory (${this.settings.actorsKeyPairsDir}) does not exist! Please remove the setting (preferred) or create the directory.`
);
}
},
async started() {
Expand Down