Bug 531005 - Sync is not working after update IWeaveCrypto.unwrapSymmetricKey NS_ERROR_FAILURE

Check that the cryptometa is unwrappable when syncing; if not purge the key and data and make a new crypto record.
This commit is contained in:
Edward Lee 2009-12-02 17:25:14 -08:00
parent eab5c8f980
commit 13dc29cda6

View File

@ -349,7 +349,26 @@ SyncEngine.prototype = {
_syncStartup: function SyncEngine__syncStartup() { _syncStartup: function SyncEngine__syncStartup() {
this._log.debug("Ensuring server crypto records are there"); this._log.debug("Ensuring server crypto records are there");
// Try getting/unwrapping the crypto record
let meta = CryptoMetas.get(this.cryptoMetaURL); let meta = CryptoMetas.get(this.cryptoMetaURL);
if (meta) {
try {
let pubkey = PubKeys.getDefaultKey();
let privkey = PrivKeys.get(pubkey.privateKeyUri);
meta.getKey(privkey, ID.get("WeaveCryptoID"));
}
catch(ex) {
// Remove traces of this bad cryptometa
this._log.debug("Purging bad data after failed unwrap crypto: " + ex);
CryptoMetas.del(this.cryptoMetaURL);
meta = null;
// Remove any potentially tained data
new Resource(this.engineURL).delete();
}
}
// Generate a new crypto record
if (!meta) { if (!meta) {
let symkey = Svc.Crypto.generateRandomKey(); let symkey = Svc.Crypto.generateRandomKey();
let pubkey = PubKeys.getDefaultKey(); let pubkey = PubKeys.getDefaultKey();