Prevent double including own S/MIME cert

This commit is contained in:
M66B 2020-09-11 09:24:56 +02:00
parent e74bc8772a
commit 2ac8840458
1 changed files with 7 additions and 1 deletions

View File

@ -2704,8 +2704,8 @@ public class FragmentCompose extends FragmentBase {
addresses.addAll(Arrays.asList(draft.bcc)); addresses.addAll(Arrays.asList(draft.bcc));
List<X509Certificate> certs = new ArrayList<>(); List<X509Certificate> certs = new ArrayList<>();
certs.add(chain[0]); // Allow sender to decrypt own message
boolean own = true;
for (Address address : addresses) { for (Address address : addresses) {
boolean found = false; boolean found = false;
Throwable cex = null; Throwable cex = null;
@ -2718,6 +2718,8 @@ public class FragmentCompose extends FragmentBase {
cert.checkValidity(); cert.checkValidity();
certs.add(cert); certs.add(cert);
found = true; found = true;
if (cert.equals(chain[0]))
own = false;
} catch (CertificateException ex) { } catch (CertificateException ex) {
Log.w(ex); Log.w(ex);
cex = ex; cex = ex;
@ -2733,6 +2735,10 @@ public class FragmentCompose extends FragmentBase {
context.getString(R.string.title_certificate_invalid, email), cex); context.getString(R.string.title_certificate_invalid, email), cex);
} }
// Allow sender to decrypt own message
if (own)
certs.add(chain[0]);
// Build signature // Build signature
BodyPart bpSignature = new MimeBodyPart(); BodyPart bpSignature = new MimeBodyPart();
bpSignature.setFileName("smime.p7s"); bpSignature.setFileName("smime.p7s");