Skip to content

Commit

Permalink
Merge pull request #1315 from assemblee-virtuelle/chore/not-require-l…
Browse files Browse the repository at this point in the history
…egacy-keyservice

Allow legacy signature service to start without `actorsKeyPairsDir` setting
  • Loading branch information
srosset81 authored Oct 14, 2024
2 parents 8cfa146 + 3f25fc2 commit f1249a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit f1249a0

Please sign in to comment.