From 39e7f2c5cbaa65e608b86ec5542fdbb82103b859 Mon Sep 17 00:00:00 2001 From: "kaie%netscape.com" Date: Thu, 13 Jun 2002 23:54:56 +0000 Subject: [PATCH] b=133995 Only allow sending encrypted mail using valid recipient certs. r=javi sr=mscott git-svn-id: svn://10.0.0.236/trunk@123274 18797224-902f-48f8-a5cc-f745e15eee43 --- .../smime/src/nsMsgComposeSecure.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mozilla/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp b/mozilla/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp index 6688376e71e..fd87d73630f 100644 --- a/mozilla/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp +++ b/mozilla/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp @@ -918,10 +918,22 @@ nsresult nsMsgComposeSecure::MimeCryptoHackCerts(const char *aRecipients, for (; count > 0; count--) { nsCOMPtr cert; certdb->GetCertByEmailAddress(nsnull, mailbox_lowercase.get(), getter_AddRefs(cert)); - if (!cert) { - // failure to find an encryption cert is - // fatal for now. We won't be able to encrypt anyway - // ssaux 12/03/2001. + PRBool foundValidCert = PR_FALSE; + + if (cert) { + PRUint32 verification_result; + + if (NS_SUCCEEDED( + cert->VerifyForUsage(nsIX509Cert::CERT_USAGE_EmailRecipient, &verification_result)) + && + nsIX509Cert::VERIFIED_OK == verification_result) + { + foundValidCert = PR_TRUE; + } + } + + if (!foundValidCert) { + // Failure to find a valid encryption cert is fatal. // here I assume that mailbox contains ascii rather than utf8. SetErrorWithParam(sendReport, NS_LITERAL_STRING("MissingRecipientEncryptionCert").get(), mailbox); res = NS_ERROR_FAILURE;