From f0bfd7224f429ce7e9acce2910b9f13e87a769e9 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 3 Dec 2018 13:16:29 -0800 Subject: [PATCH] Handle having a null sender certificate at send time. Fixes #8425 --- src/org/thoughtcrime/securesms/jobs/PushSendJob.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushSendJob.java index 0b4eff3e14..c4f0ee6ced 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushSendJob.java @@ -210,7 +210,13 @@ public abstract class PushSendJob extends SendJob { protected void rotateSenderCertificateIfNecessary() throws IOException { try { - SenderCertificate certificate = new SenderCertificate(TextSecurePreferences.getUnidentifiedAccessCertificate(context)); + byte[] certificateBytes = TextSecurePreferences.getUnidentifiedAccessCertificate(context); + + if (certificateBytes == null) { + throw new InvalidCertificateException("No certificate was present."); + } + + SenderCertificate certificate = new SenderCertificate(certificateBytes); if (System.currentTimeMillis() > (certificate.getExpiration() - CERTIFICATE_EXPIRATION_BUFFER)) { throw new InvalidCertificateException("Certificate is expired, or close to it. Expires on: " + certificate.getExpiration() + ", currently: " + System.currentTimeMillis());