Solved

CAPICOM on 64 bit machine

Posted on 2011-03-08
11
2,252 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
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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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!
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now