Solved

CAPICOM on 64 bit machine

Posted on 2011-03-08
11
2,271 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

11 Experts available now in Live!

Get 1:1 Help Now