Skip to content

Commit

Permalink
Catch exceptions trying to import CRLs and Certs in GetDigitalSignatu…
Browse files Browse the repository at this point in the history
…res()

Fixes issue #304
  • Loading branch information
jstedfast committed May 3, 2017
1 parent 61d8e5a commit 2959425
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions MimeKit/Cryptography/SecureMimeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,12 @@ protected DigitalSignatureCollection GetDigitalSignatures (CmsSignedDataParser p
var crls = parser.GetCrls ("Collection");
var store = parser.GetSignerInfos ();

// FIXME: we might not want to import these...
foreach (X509Crl crl in crls.GetMatches (null))
Import (crl);
try {
// FIXME: we might not want to import these...
foreach (X509Crl crl in crls.GetMatches (null))
Import (crl);
} catch {
}

foreach (SignerInformation signerInfo in store.GetSigners ()) {
var certificate = GetCertificate (certificates, signerInfo.SignerID);
Expand Down Expand Up @@ -983,10 +986,14 @@ protected DigitalSignatureCollection GetDigitalSignatures (CmsSignedDataParser p

if (certificate != null) {
signature.SignerCertificate = new SecureMimeDigitalCertificate (certificate);
if (algorithms.Count > 0 && signedDate != null)
if (algorithms.Count > 0 && signedDate != null) {
UpdateSecureMimeCapabilities (certificate, signature.EncryptionAlgorithms, signedDate.Value);
else
Import (certificate);
} else {
try {
Import (certificate);
} catch {
}
}
}

var anchors = GetTrustedAnchors ();
Expand Down

0 comments on commit 2959425

Please sign in to comment.