Included valid S/MIME public keys for recipients

This commit is contained in:
M66B 2020-05-06 13:02:41 +02:00
parent ae27d73f33
commit 6ff1a122e2
1 changed files with 21 additions and 14 deletions

View File

@ -2434,23 +2434,30 @@ public class FragmentCompose extends FragmentBase {
certs.add(chain[0]); // Allow sender to decrypt own message certs.add(chain[0]); // Allow sender to decrypt own message
for (Address address : addresses) { for (Address address : addresses) {
boolean found = false;
Throwable cex = null;
String email = ((InternetAddress) address).getAddress(); String email = ((InternetAddress) address).getAddress();
List<EntityCertificate> acertificates = db.certificate().getCertificateByEmail(email); List<EntityCertificate> acertificates = db.certificate().getCertificateByEmail(email);
if (acertificates == null || acertificates.size() == 0) if (acertificates != null)
throw new IllegalArgumentException( for (EntityCertificate acertificate : acertificates) {
context.getString(R.string.title_certificate_missing, email), new CertificateException()); X509Certificate cert = acertificate.getCertificate();
try {
for (EntityCertificate acertificate : acertificates) { cert.checkValidity();
X509Certificate cert = acertificate.getCertificate(); certs.add(cert);
try { found = true;
cert.checkValidity(); } catch (CertificateException ex) {
} catch (CertificateException ex) { Log.w(ex);
throw new IllegalArgumentException( cex = ex;
context.getString(R.string.title_certificate_invalid, email), ex); }
} }
certs.add(cert);
} if (!found)
if (cex == null)
throw new IllegalArgumentException(
context.getString(R.string.title_certificate_missing, email));
else
throw new IllegalArgumentException(
context.getString(R.string.title_certificate_invalid, email), cex);
} }
// Build signature // Build signature