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';
|
// TODO: uncomment this once we want to start registering UUID support
|
||||||
if (
|
// const hasRegisteredUuidSupportKey = 'hasRegisteredUuidSupport';
|
||||||
!storage.get(hasRegisteredUuidSupportKey) &&
|
// if (
|
||||||
textsecure.storage.user.getUuid()
|
// !storage.get(hasRegisteredUuidSupportKey) &&
|
||||||
) {
|
// textsecure.storage.user.getUuid()
|
||||||
const server = WebAPI.connect({
|
// ) {
|
||||||
username: USERNAME || OLD_USERNAME,
|
// const server = WebAPI.connect({
|
||||||
password: PASSWORD,
|
// username: USERNAME || OLD_USERNAME,
|
||||||
});
|
// password: PASSWORD,
|
||||||
try {
|
// });
|
||||||
await server.registerCapabilities({ uuid: true });
|
// try {
|
||||||
storage.put(hasRegisteredUuidSupportKey, true);
|
// await server.registerCapabilities({ uuid: true });
|
||||||
} catch (error) {
|
// storage.put(hasRegisteredUuidSupportKey, true);
|
||||||
window.log.error(
|
// } catch (error) {
|
||||||
'Error: Unable to register support for UUID messages.',
|
// window.log.error(
|
||||||
error && error.stack ? error.stack : error
|
// 'Error: Unable to register support for UUID messages.',
|
||||||
);
|
// error && error.stack ? error.stack : error
|
||||||
}
|
// );
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const deviceId = textsecure.storage.user.getDeviceId();
|
const deviceId = textsecure.storage.user.getDeviceId();
|
||||||
|
|
||||||
|
|
|
@ -1391,14 +1391,10 @@
|
||||||
|
|
||||||
getSendOptions(options = {}) {
|
getSendOptions(options = {}) {
|
||||||
const senderCertificate = storage.get('senderCertificate');
|
const senderCertificate = storage.get('senderCertificate');
|
||||||
const senderCertificateWithUuid = storage.get(
|
|
||||||
'senderCertificateWithUuid'
|
|
||||||
);
|
|
||||||
const sendMetadata = this.getSendMetadata(options);
|
const sendMetadata = this.getSendMetadata(options);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
senderCertificate,
|
senderCertificate,
|
||||||
senderCertificateWithUuid,
|
|
||||||
sendMetadata,
|
sendMetadata,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -1456,7 +1452,9 @@
|
||||||
window.Signal.Crypto.arrayBufferToBase64(
|
window.Signal.Crypto.arrayBufferToBase64(
|
||||||
window.Signal.Crypto.getRandomBytes(16)
|
window.Signal.Crypto.getRandomBytes(16)
|
||||||
),
|
),
|
||||||
useUuidSenderCert: uuidCapable,
|
// Indicates that a client is capable of receiving uuid-only messages.
|
||||||
|
// Not used yet.
|
||||||
|
uuidCapable,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...(e164 ? { [e164]: info } : {}),
|
...(e164 ? { [e164]: info } : {}),
|
||||||
|
@ -1475,7 +1473,9 @@
|
||||||
: window.Signal.Crypto.arrayBufferToBase64(
|
: window.Signal.Crypto.arrayBufferToBase64(
|
||||||
window.Signal.Crypto.getRandomBytes(16)
|
window.Signal.Crypto.getRandomBytes(16)
|
||||||
),
|
),
|
||||||
useUuidSenderCert: uuidCapable,
|
// Indicates that a client is capable of receiving uuid-only messages.
|
||||||
|
// Not used yet.
|
||||||
|
uuidCapable,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -81,29 +81,29 @@ function initialize({ events, storage, navigator, logger }) {
|
||||||
password: PASSWORD,
|
password: PASSWORD,
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(
|
const { certificate } = await server.getSenderCertificate();
|
||||||
[false, true].map(async withUuid => {
|
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(certificate);
|
||||||
const { certificate } = await server.getSenderCertificate(withUuid);
|
const decodedContainer = textsecure.protobuf.SenderCertificate.decode(
|
||||||
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(
|
arrayBuffer
|
||||||
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 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;
|
scheduledTime = null;
|
||||||
scheduleNextRotation();
|
scheduleNextRotation();
|
||||||
|
|
|
@ -618,7 +618,6 @@ async function removeAllSignedPreKeys() {
|
||||||
const ITEM_KEYS: { [key: string]: Array<string> | undefined } = {
|
const ITEM_KEYS: { [key: string]: Array<string> | undefined } = {
|
||||||
identityKey: ['value.pubKey', 'value.privKey'],
|
identityKey: ['value.pubKey', 'value.privKey'],
|
||||||
senderCertificate: ['value.serialized'],
|
senderCertificate: ['value.serialized'],
|
||||||
senderCertificateWithUuid: ['value.serialized'],
|
|
||||||
signaling_key: ['value'],
|
signaling_key: ['value'],
|
||||||
profileKey: ['value'],
|
profileKey: ['value'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,6 @@ export default class OutgoingMessage {
|
||||||
|
|
||||||
sendMetadata?: SendMetadataType;
|
sendMetadata?: SendMetadataType;
|
||||||
senderCertificate?: ArrayBuffer;
|
senderCertificate?: ArrayBuffer;
|
||||||
senderCertificateWithUuid?: ArrayBuffer;
|
|
||||||
online?: boolean;
|
online?: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -70,15 +69,9 @@ export default class OutgoingMessage {
|
||||||
this.failoverIdentifiers = [];
|
this.failoverIdentifiers = [];
|
||||||
this.unidentifiedDeliveries = [];
|
this.unidentifiedDeliveries = [];
|
||||||
|
|
||||||
const {
|
const { sendMetadata, senderCertificate, online } = options || ({} as any);
|
||||||
sendMetadata,
|
|
||||||
senderCertificate,
|
|
||||||
senderCertificateWithUuid,
|
|
||||||
online,
|
|
||||||
} = options || ({} as any);
|
|
||||||
this.sendMetadata = sendMetadata;
|
this.sendMetadata = sendMetadata;
|
||||||
this.senderCertificate = senderCertificate;
|
this.senderCertificate = senderCertificate;
|
||||||
this.senderCertificateWithUuid = senderCertificateWithUuid;
|
|
||||||
this.online = online;
|
this.online = online;
|
||||||
}
|
}
|
||||||
numberCompleted() {
|
numberCompleted() {
|
||||||
|
@ -314,15 +307,12 @@ export default class OutgoingMessage {
|
||||||
} = {};
|
} = {};
|
||||||
const plaintext = this.getPlaintext();
|
const plaintext = this.getPlaintext();
|
||||||
|
|
||||||
const { sendMetadata } = this;
|
const { sendMetadata, senderCertificate } = this;
|
||||||
const info =
|
const info =
|
||||||
sendMetadata && sendMetadata[identifier]
|
sendMetadata && sendMetadata[identifier]
|
||||||
? sendMetadata[identifier]
|
? sendMetadata[identifier]
|
||||||
: { accessKey: undefined, useUuidSenderCert: undefined };
|
: { accessKey: undefined };
|
||||||
const { accessKey, useUuidSenderCert } = info;
|
const { accessKey } = info;
|
||||||
const senderCertificate = useUuidSenderCert
|
|
||||||
? this.senderCertificateWithUuid
|
|
||||||
: this.senderCertificate;
|
|
||||||
|
|
||||||
if (accessKey && !senderCertificate) {
|
if (accessKey && !senderCertificate) {
|
||||||
window.log.warn(
|
window.log.warn(
|
||||||
|
|
|
@ -35,7 +35,6 @@ function base64ToArrayBuffer(string: string): ArrayBuffer {
|
||||||
export type SendMetadataType = {
|
export type SendMetadataType = {
|
||||||
[identifier: string]: {
|
[identifier: string]: {
|
||||||
accessKey: string;
|
accessKey: string;
|
||||||
useUuidSenderCert: boolean;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ type GroupMemberType = {
|
||||||
|
|
||||||
export type SendOptionsType = {
|
export type SendOptionsType = {
|
||||||
senderCertificate?: ArrayBuffer;
|
senderCertificate?: ArrayBuffer;
|
||||||
senderCertificateWithUuid?: ArrayBuffer;
|
|
||||||
sendMetadata?: SendMetadataType;
|
sendMetadata?: SendMetadataType;
|
||||||
online?: boolean;
|
online?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -790,13 +790,13 @@ export function initialize({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSenderCertificate(withUuid = false) {
|
async function getSenderCertificate() {
|
||||||
return _ajax({
|
return _ajax({
|
||||||
call: 'deliveryCert',
|
call: 'deliveryCert',
|
||||||
httpType: 'GET',
|
httpType: 'GET',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
validateResponse: { certificate: 'string' },
|
validateResponse: { certificate: 'string' },
|
||||||
urlParameters: withUuid ? '?includeUuid=true' : undefined,
|
urlParameters: '?includeUuid=true',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,9 +917,11 @@ export function initialize({
|
||||||
) {
|
) {
|
||||||
const { accessKey } = options;
|
const { accessKey } = options;
|
||||||
const jsonData: any = {
|
const jsonData: any = {
|
||||||
capabilities: {
|
// tslint:disable-next-line: no-suspicious-comment
|
||||||
uuid: true,
|
// TODO: uncomment this once we want to start registering UUID support
|
||||||
},
|
// capabilities: {
|
||||||
|
// uuid: true,
|
||||||
|
// },
|
||||||
fetchesMessages: true,
|
fetchesMessages: true,
|
||||||
name: deviceName ? deviceName : undefined,
|
name: deviceName ? deviceName : undefined,
|
||||||
registrationId,
|
registrationId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue