From c53b07a35a73d8a83c0e1bfaebdb0284e03b398d Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 24 Mar 2020 15:49:51 +0000 Subject: [PATCH 1/2] Add logging when secrets are missing from cache --- src/CrossSigningManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CrossSigningManager.js b/src/CrossSigningManager.js index 5c254bbd00..097464ee43 100644 --- a/src/CrossSigningManager.js +++ b/src/CrossSigningManager.js @@ -149,9 +149,15 @@ const onSecretRequested = async function({ if (!callbacks.getCrossSigningKeyCache) return; if (name === "m.cross_signing.self_signing") { const key = await callbacks.getCrossSigningKeyCache("self_signing"); + if (!key) { + console.log(`self_signing requested by ${deviceId}, but not found in cache`); + } return key && encodeBase64(key); } else if (name === "m.cross_signing.user_signing") { const key = await callbacks.getCrossSigningKeyCache("user_signing"); + if (!key) { + console.log(`user_signing requested by ${deviceId}, but not found in cache`); + } return key && encodeBase64(key); } console.warn("onSecretRequested didn't recognise the secret named ", name); From 1c802cc6afd6e27effc791238e07da13e8dcbf86 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 24 Mar 2020 15:50:08 +0000 Subject: [PATCH 2/2] Show private key cache state in debug panel --- .../views/settings/CrossSigningPanel.js | 17 +++++++++++++++++ src/i18n/strings/en_EN.json | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/components/views/settings/CrossSigningPanel.js b/src/components/views/settings/CrossSigningPanel.js index cf47c797fc..b960434ca1 100644 --- a/src/components/views/settings/CrossSigningPanel.js +++ b/src/components/views/settings/CrossSigningPanel.js @@ -32,6 +32,8 @@ export default class CrossSigningPanel extends React.PureComponent { error: null, crossSigningPublicKeysOnDevice: false, crossSigningPrivateKeysInStorage: false, + selfSigningPrivateKeyCached: false, + userSigningPrivateKeyCached: false, secretStorageKeyInAccount: false, secretStorageKeyNeedsUpgrade: null, }; @@ -71,10 +73,13 @@ export default class CrossSigningPanel extends React.PureComponent { async _getUpdatedStatus() { const cli = MatrixClientPeg.get(); + const pkCache = cli.getCrossSigningCacheCallbacks(); const crossSigning = cli._crypto._crossSigningInfo; const secretStorage = cli._crypto._secretStorage; const crossSigningPublicKeysOnDevice = crossSigning.getId(); const crossSigningPrivateKeysInStorage = await crossSigning.isStoredInSecretStorage(secretStorage); + const selfSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("self_signing")); + const userSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("user_signing")); const secretStorageKeyInAccount = await secretStorage.hasKey(); const homeserverSupportsCrossSigning = await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"); @@ -84,6 +89,8 @@ export default class CrossSigningPanel extends React.PureComponent { this.setState({ crossSigningPublicKeysOnDevice, crossSigningPrivateKeysInStorage, + selfSigningPrivateKeyCached, + userSigningPrivateKeyCached, secretStorageKeyInAccount, homeserverSupportsCrossSigning, crossSigningReady, @@ -130,6 +137,8 @@ export default class CrossSigningPanel extends React.PureComponent { error, crossSigningPublicKeysOnDevice, crossSigningPrivateKeysInStorage, + selfSigningPrivateKeyCached, + userSigningPrivateKeyCached, secretStorageKeyInAccount, homeserverSupportsCrossSigning, crossSigningReady, @@ -209,6 +218,14 @@ export default class CrossSigningPanel extends React.PureComponent { {_t("Cross-signing private keys:")} {crossSigningPrivateKeysInStorage ? _t("in secret storage") : _t("not found")} + + {_t("Self signing private key:")} + {selfSigningPrivateKeyCached ? _t("cached locally") : _t("not found locally")} + + + {_t("User signing private key:")} + {userSigningPrivateKeyCached ? _t("cached locally") : _t("not found locally")} + {_t("Secret storage public key:")} {secretStorageKeyInAccount ? _t("in account data") : _t("not found")} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 57b39309b0..12bd462937 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -582,6 +582,10 @@ "not found": "not found", "Cross-signing private keys:": "Cross-signing private keys:", "in secret storage": "in secret storage", + "Self signing private key:": "Self signing private key:", + "cached locally": "cached locally", + "not found locally": "not found locally", + "User signing private key:": "User signing private key:", "Secret storage public key:": "Secret storage public key:", "in account data": "in account data", "Homeserver feature support:": "Homeserver feature support:",