+1 vote

How i Can check when i read a new email signed if the signature is correct ?

by

1 Answer

0 votes
 
Best answer

No exception from this code means that the email's signature is valid:

using (Imap imap = new Imap())
{
    imap.Connect("imap.example.com"); // or ConnectSSL
    imap.UseBestLogin("user", "password");

    MailBuilder builder = new MailBuilder();
    foreach (long uid in imap.GetAll())
    {
        IMail email = builder.CreateFromEml(
            imap.GetMessageByUID(uid));

        // Check signature
        if (email.IsSigned == true)
            email.CheckSignature(true);
    }
    imap.Close();
}

If verifySignatureOnly parameter is true, only the digital signatures are verified.

If it is false, the digital signatures are verified, the signers' certificates are validated (self-signed certificates are invalid when using this option).

https://www.limilabs.com/blog/validate-smime-emails

by (301k points)
...