Solved

CAPICOM on 64 bit machine

Posted on 2011-03-08
11
2,334 Views
Last Modified: 2012-05-11
Hi All,

I am using the capicom dll to sign some xml messages and send them using BizTalk. It was working fine on the test server, but on the production server which is 64 bit I get this error when CAPICOM dll is being called I get this error:

Retrieving the COM class factory for component with CLSID {94AFFFCC-6C05-4814-B123-A941105AA77F} failed due to the following error: 80040154.

so I did a little searching and apperently the capicom is not supported in 64 bit is the conclusion I have reached.

So my question is:
1- Is there anyway to make this work in 64 bit without needing to write some additional code?
2- If not, then how do I accomplish what is being done in the code below?
public string SignIt(string sClearText, bool bDetached)
        {
            EventLog.WriteEntry(
                    "SignatureMgr::SignIt",
                    WindowsIdentity.GetCurrent().Name,
                    EventLogEntryType.Information
                );

            SignedData signedData = new SignedDataClass();
            byte[] binArr = Encoding.UTF8.GetBytes(sClearText);
            Utilities utils = new CAPICOM.UtilitiesClass();
            signedData.set_Content(utils.ByteArrayToBinaryString(binArr));
            Store store = new Store();
                        store.Open(
                    CAPICOM_STORE_LOCATION.CAPICOM_LOCAL_MACHINE_STORE,
                    "MY",
                    CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_READ_ONLY
                );

            Signer signer = new Signer();
                      string certSimpleName = null;
            foreach (object cert in store.Certificates)
            {
                certSimpleName =
                    ((Certificate)cert).GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME).ToLower();
                System.Diagnostics.EventLog.WriteEntry(
                        "CSadadMessags::CMessageSigner",
                        certSimpleName + "=" + _certName,
                        System.Diagnostics.EventLogEntryType.Information
                    );

                             if (certSimpleName == _certName.ToLower())
                {
                    signer.Certificate = (Certificate)cert;
                    break;
                }
            }

            string signedText =
                signedData.Sign(
                    signer,
                    bDetached,
                    CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64
                );

                        return signedText;
        }

Open in new window

0
Comment
Question by:Samooramad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 13

Expert Comment

by:agarwalrahul
ID: 35070501
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35071562
You could try to build your code to target x86 instead of x64 or Any CPU. This will force your application to run in 32-bit mode and possibly the CAPICOM dll will work.

BuildPlatformTarget
0
 

Author Comment

by:Samooramad
ID: 35079181
you mean change it for the project which is referencing the CAPICOM dll right?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:Samooramad
ID: 35079814
agarwalrahul,

I followed those steps and when registering the dll got this error ss
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35080015
Capicom isn't available in 64-bit. If you want to continue using capicom you have no choice but to force your project to 32-bit by setting it to x86.  Projects that reference other projects must match - i.e. a 64-bit project cannot reference a 32-bit project, so you will probably need to make sure all the projects in your solution are either "x86" or "AnyCPU".
0
 

Author Comment

by:Samooramad
ID: 35080389
still not working
0
 

Author Comment

by:Samooramad
ID: 35080407
what can i use instead of Capicom?
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35082783
Here is what I found:

MSDN - Alternatives to Using CAPICOM
http://msdn.microsoft.com/en-us/library/cc778518%28v=vs.85%29.aspx
0
 

Accepted Solution

by:
Samooramad earned 0 total points
ID: 35085740
I tried a lot of stuff... finally found something I could use at (code is posted)

http://www.leandrodg.com.ar/blog/2010/03/encryption-and-decryption-with-x-509-certificates/

the only issue is when I run it, I get the outputed encrypted data with a few header lines before it. How do I get rid of that? any ideas?


Content-ID: {8463E39C-7BC6-4F0C-912F-27824D1D01E9}
Content-Description: body
Bcc:
MIME-Version: 1.0
Content-type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64

MIIBtwYJKoZIhvcNAQcDoIIBqDCCAaQCAQAxgfIwge8CAQAwWDBSMQswCQYDVQQGEwJTQTENMAsG
A1UEChMEU0FNQTEbMBkGA1UECxMSU0FNQSBlVHJ1c3QgQ2VudGVyMRcwFQYDVQQDEw5TQU1BIFNo
YXJlZCBDQQICNgwwDQYJKoZIhvcNAQEBBQAEgYCD3qSwnhBeZK/xTNbHIDYKlOW3xhWJ3z106r1g
NPLNkHXoB5nPef+NqINZ56r/2CqxqQ3O30qL34WE7dikF7C6cVAdpVNTmghk/wkOy2olbge/hzfi
v+AXTVvI2k/Hd2TL3yvqzXn2kUs/cVEuJP+z4xFcvn8w2/TXAzDkHAtNDjCBqQYJKoZIhvcNAQcB
MBkGCCqGSIb3DQMCMA0CAToECJZmG/AMxJ5igIGAHZwD/mAQVXK199o5AS0Mx0/2gbIfvxDun6oT
mHul1j+4SkdmO4dd/32EwtoZb/vkkKtqQdsXKckdqKXqQsnzVs2LzJIKI+J6VCCmyBAaboyOPwls
J4TLAIycJVAlYaW4UGTcIIz9XjgK6BxSEZ4ad0iC52KSZgxLifuKidjXxqg=

0
 

Author Comment

by:Samooramad
ID: 35086133
figured it out

replaced this line:

string result = EnvelopEncryptedContent(encryptedContent);

with this line:

string result = encryptedContent;

Thanks all
0
 

Author Closing Comment

by:Samooramad
ID: 35126350
Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to escape alias names for Oracle query 1 26
Nested forach loop to linq 3 30
c#, datatable, aspx 4 25
Check only one toolstripmenu item 12 31
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question