Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CAPICOM on 64 bit machine

Posted on 2011-03-08
11
Medium Priority
?
2,414 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 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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