Always use sender certificates including UUID
This commit is contained in:
parent
7a55c68c6c
commit
d6d2d242d4
7 changed files with 59 additions and 69 deletions
|
@ -1702,25 +1702,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
const hasRegisteredUuidSupportKey = 'hasRegisteredUuidSupport';
|
||||
if (
|
||||
!storage.get(hasRegisteredUuidSupportKey) &&
|
||||
textsecure.storage.user.getUuid()
|
||||
) {
|
||||
const server = WebAPI.connect({
|
||||
username: USERNAME || OLD_USERNAME,
|
||||
password: PASSWORD,
|
||||
});
|
||||
try {
|
||||
await server.registerCapabilities({ uuid: true });
|
||||
storage.put(hasRegisteredUuidSupportKey, true);
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
'Error: Unable to register support for UUID messages.',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
}
|
||||
}
|
||||
// TODO: uncomment this once we want to start registering UUID support
|
||||
// const hasRegisteredUuidSupportKey = 'hasRegisteredUuidSupport';
|
||||
// if (
|
||||
// !storage.get(hasRegisteredUuidSupportKey) &&
|
||||
// textsecure.storage.user.getUuid()
|
||||
// ) {
|
||||
// const server = WebAPI.connect({
|
||||
// username: USERNAME || OLD_USERNAME,
|
||||
// password: PASSWORD,
|
||||
// });
|
||||
// try {
|
||||
// await server.registerCapabilities({ uuid: true });
|
||||
// storage.put(hasRegisteredUuidSupportKey, true);
|
||||
// } catch (error) {
|
||||
// window.log.error(
|
||||
// 'Error: Unable to register support for UUID messages.',
|
||||
// error && error.stack ? error.stack : error
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
const deviceId = textsecure.storage.user.getDeviceId();
|
||||
|
||||
|
|
|
@ -1391,14 +1391,10 @@
|
|||
|
||||
getSendOptions(options = {}) {
|
||||
const senderCertificate = storage.get('senderCertificate');
|
||||
const senderCertificateWithUuid = storage.get(
|
||||
'senderCertificateWithUuid'
|
||||
);
|
||||
const sendMetadata = this.getSendMetadata(options);
|
||||
|
||||
return {
|
||||
senderCertificate,
|
||||
senderCertificateWithUuid,
|
||||
sendMetadata,
|
||||
};
|
||||
},
|
||||
|
@ -1456,7 +1452,9 @@
|
|||
window.Signal.Crypto.arrayBufferToBase64(
|
||||
window.Signal.Crypto.getRandomBytes(16)
|
||||
),
|
||||
useUuidSenderCert: uuidCapable,
|
||||
// Indicates that a client is capable of receiving uuid-only messages.
|
||||
// Not used yet.
|
||||
uuidCapable,
|
||||
};
|
||||
return {
|
||||
...(e164 ? { [e164]: info } : {}),
|
||||
|
@ -1475,7 +1473,9 @@
|
|||
: window.Signal.Crypto.arrayBufferToBase64(
|
||||
window.Signal.Crypto.getRandomBytes(16)
|
||||
),
|
||||
useUuidSenderCert: uuidCapable,
|
||||
// Indicates that a client is capable of receiving uuid-only messages.
|
||||
// Not used yet.
|
||||
uuidCapable,
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -81,29 +81,29 @@ function initialize({ events, storage, navigator, logger }) {
|
|||
password: PASSWORD,
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
[false, true].map(async withUuid => {
|
||||
const { certificate } = await server.getSenderCertificate(withUuid);
|
||||
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(
|
||||
certificate
|
||||
);
|
||||
const decodedContainer = textsecure.protobuf.SenderCertificate.decode(
|
||||
arrayBuffer
|
||||
);
|
||||
const decodedCert = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
||||
decodedContainer.certificate
|
||||
);
|
||||
|
||||
// We don't want to send a protobuf-generated object across IPC, so we make
|
||||
// our own object.
|
||||
const toSave = {
|
||||
expires: decodedCert.expires.toNumber(),
|
||||
serialized: arrayBuffer,
|
||||
};
|
||||
|
||||
storage.put(`senderCertificate${withUuid ? 'WithUuid' : ''}`, toSave);
|
||||
})
|
||||
const { certificate } = await server.getSenderCertificate();
|
||||
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(certificate);
|
||||
const decodedContainer = textsecure.protobuf.SenderCertificate.decode(
|
||||
arrayBuffer
|
||||
);
|
||||
const decodedCert = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
||||
decodedContainer.certificate
|
||||
);
|
||||
|
||||
// We don't want to send a protobuf-generated object across IPC, so we make
|
||||
// our own object.
|
||||
const toSave = {
|
||||
expires: decodedCert.expires.toNumber(),
|
||||
serialized: arrayBuffer,
|
||||
};
|
||||
|
||||
storage.put('senderCertificate', toSave);
|
||||
|
||||
const oldCertKey = 'senderCertificateWithUuid';
|
||||
const oldUuidCert = storage.get(oldCertKey);
|
||||
if (oldUuidCert) {
|
||||
await storage.remove(oldCertKey);
|
||||
}
|
||||
|
||||
scheduledTime = null;
|
||||
scheduleNextRotation();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue