Author Topic: Decrypt Mail  (Read 636 times)

mdonath

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Decrypt Mail
« on: January 10, 2018, 08:52:23 AM »
I have 2 emails (my and other). For both I have a .pfx file and a .cer file.
I succeed in sending a signed and encrypted mail:

   CkMailMan mailman;
   //...
   auto email = std::make_unique<CkEmail>();
   email->put_SendSigned(true);
   mailman.AddPfxSourceFile("my.pfx", "mypass");
   auto cert = std::make_unique<CkCert>();
   cert->LoadFromFile("other.cer");
   email->put_SendEncrypted(true);
   email->put_Pkcs7CryptAlg("3des");
   email->put_Pkcs7KeyLength(192);
   success = email->SetEncryptCert(*cert);
   mailman.put_OpaqueSigning(true);
   // ...
   mailman.SendEmail(*email);


But if I try to decrypt this mail in the other account:

   CkImap imap;
   //...
   CkMessageSet* messageSet = imap.Search("ALL",true);
   CkEmailBundle* bundle = imap.FetchHeaders(*messageSet);
   for (int i = 0; i < bundle->get_MessageCount(); i++) {
      CkEmail* email = bundle->GetEmail(i);
      email->AddPfxSourceFile("other.pfx", "otherpass");
      if (email->get_ReceivedEncrypted() == true)
            if (email->get_Decrypted() == true)
               Ok();

      delete email;
   }


I never reach ok (email->get_ReceivedEncrypted()  returns always false).

Any idea what's wrong here?

Chilkat

  • Administrator
  • Full Member
  • *****
  • Posts: 103
  • Karma: +6/-0
    • View Profile
Re: Decrypt Mail
« Reply #1 on: January 12, 2018, 12:49:37 PM »
You're fetching headers...

mdonath

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Decrypt Mail
« Reply #2 on: January 22, 2018, 09:15:23 AM »
Ok, that's it.