0 votes
by (120 points)


How to store digital sign in received mail and what are different ways to store digital sign

After storing the digital sign and how to use the same sign for encrypt the mail

Thanks Chandru

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (70.2k points)

Public-key of the received signed mail can be stored as follows:

// load a mail or retrieve it using POP3 or IMAP
MailMessage receivedSignedMail = new MailMessage();

// store signer certificate
if (receivedSignedMail.Signers.Count > 0)
    // get the first signer certificate
    Certificate signerCert = receivedSignedMail.Signers[0].Certificate;

    // save the certificate to a file
    File.WriteAllBytes("path.cer", signerCert.GetRawCertData());

The saved Public-key can be load and used for encryption as follows:

// load certificate
Certificate cert = Certificate.LoadDer("path.cer");

// prepare a mail for encryption
MailMessage encryptedMailToSend = new MailMessage();
// ...

// encrypt the mail

For information about certificates, signing and encrypting please visit our blog or Wikipedia.