CAPICOM EnvelopedData Troubles

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9uYXRoYW4gVy4gWmFsZXNraQ==?=, Aug 2, 2005.

  1. I am trying to use the CAPICOM Package to Send Secure Emails, however, I am
    having a bit of trouble in getting it to work. I am able to get the proper
    certificate, and seemingly encode the 'EnvelopedData' correctly, but when
    attempting to open the sent message in Outlook I receive a: "Can't open this
    item. Your Digital ID name can not be found by the underlying security
    system." Error. I am unsure what this means exactly as it is not something I
    was able to query with helpful results on Google, so I was wondering if
    someone else had this issue, and knew how to resolve it.

    If anyone has a good example of this process in action I would very much
    appreciate a good example, so that I can perhaps see my error(s).

    NOTE: I was able to Encrypt and send Messages using ChilkatDotNet so I would
    assume i'm just overlooking some step of the process.

    Since I find it very likely I'm doing something incorrect somewhere along
    the encryption process, I have attached my source below. Any help would be
    greatly appreciated:


    //CLASS VARIABLES

    static private String _currStoreName = "My";
    static StoreClass _oCurrStore;

    private System.Web.Mail.MailMessage theMessage;

    private Certificates oCerts;
    private Certificate oCert;

    private EnvelopedData encryptedMessage;


    //SOURCE CODE

    private void btnSubmit_Click(object sender, System.EventArgs e)
    {

    _oCurrStore = new StoreClass();
    _oCurrStore.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE,
    _currStoreName,CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY |
    CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);

    oCerts = (Certificates)_oCurrStore.Certificates;

    foreach(Certificate cert in oCerts)
    {
    oCert = cert;
    }

    theMessage = new System.Web.Mail.MailMessage();

    theMessage.To = "";
    theMessage.From = "";
    theMessage.Subject = "This is the Subject";

    encryptedMessage = new EnvelopedData();
    encryptedMessage.Content = "Hello World!";
    encryptedMessage.Recipients.Add(oCert);

    Response.Write("<B>Subject Email Name: </B>" +
    oCert.GetInfo(CAPICOM.CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME) + "<BR>");

    string smimeMessage =
    encryptedMessage.Encrypt(CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);

    StreamWriter outStream = new StreamWriter("C:\\DEV\\smime.p7m", false);
    outStream.WriteLine(smimeMessage);
    outStream.Close();

    theMessage.Attachments.Add(new
    System.Web.Mail.MailAttachment("C:\\DEV\\smime.p7m"));

    theMessage.Headers.Add("Content-Type",
    "application/x-pkcs7-mime;smime-type=enveloped-data;");
    //theMessage.Headers.Add("Content-Transfer-Encoding", "base64");
    theMessage.Headers.Remove("Content-Class");

    System.Web.Mail.SmtpMail.SmtpServer = "mail.dovetailinternet.com";
    System.Web.Mail.SmtpMail.Send(theMessage);

    File.Delete("C:\\DEV\\smime.p7m");
    }
     
    =?Utf-8?B?Sm9uYXRoYW4gVy4gWmFsZXNraQ==?=, Aug 2, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TW9oaXQ=?=

    CapiCom?

    =?Utf-8?B?TW9oaXQ=?=, May 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    803
    Kevin Spencer
    May 12, 2004
  2. Neil S.
    Replies:
    1
    Views:
    547
    Richard Herring
    Aug 20, 2004
  3. =?ISO-8859-1?Q?st=E9phane_bard?=

    using capicom with python

    =?ISO-8859-1?Q?st=E9phane_bard?=, Jul 17, 2006, in forum: Python
    Replies:
    2
    Views:
    571
    =?ISO-8859-1?Q?st=E9phane_bard?=
    Jul 20, 2006
  4. Gary at Arrowpoint

    Access is Denied Exception using Interop.CAPICOM.dll (or CAPICOM.d

    Gary at Arrowpoint, Aug 30, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    393
    Gary at Arrowpoint
    Aug 30, 2005
  5. Alexei Pashin

    Troubles with CAPICOM EnvelopedData.Decrypt

    Alexei Pashin, Jul 15, 2003, in forum: ASP General
    Replies:
    0
    Views:
    193
    Alexei Pashin
    Jul 15, 2003
Loading...

Share This Page