tag:blogger.com,1999:blog-9537945.post-50396683060014205532008-01-22T22:56:00.000-06:002008-01-22T23:30:22.978-06:00CAPICOM ... UGH!I'm working on an install that requires me to write some custom actions to interact with the certificate stores. I seems there are four different ways to do it out there:<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/e78byta0(VS.80).aspx"><span class="blsp-spelling-error" id="SPELLING_ERROR_0">certmgr</span>.<span class="blsp-spelling-error" id="SPELLING_ERROR_1">exe</span></a> : The way the developer suggests doing it. Of course it's a .NET <span class="blsp-spelling-error" id="SPELLING_ERROR_2">SDK</span> utility with <span class="blsp-spelling-error" id="SPELLING_ERROR_3">redist</span> rights.<br /><a href="http://msdn2.microsoft.com/en-us/library/aa380256(VS.85).aspx"><span class="blsp-spelling-error" id="SPELLING_ERROR_4">cryptoAPI</span></a> : Win32 <span class="blsp-spelling-error" id="SPELLING_ERROR_5">API</span><br /><a href="http://msdn2.microsoft.com/en-us/library/aa375732(VS.85).aspx"><span class="blsp-spelling-error" id="SPELLING_ERROR_6">CAPICOM</span></a> : <span class="blsp-spelling-error" id="SPELLING_ERROR_7">Scriptable</span> COM<br /><a href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.x509certificates.aspx">System.Security.Cryptography.X509Certificates</a> : .NET Framework<br /><br />After a whole lot of digging I decided ( for now ) to settle on <span class="blsp-spelling-error" id="SPELLING_ERROR_8">CAPICOM</span>. I found the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=860EE43A-A843-462F-ABB5-FF88EA5896F6&displaylang=en"><span class="blsp-spelling-error" id="SPELLING_ERROR_9">CAPICOM</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_10">SDK</span></a> and example <span class="blsp-spelling-error" id="SPELLING_ERROR_11">VBScript</span> file that shows how to load a certificate into the store. I quickly ported that over to <span class="blsp-spelling-error" id="SPELLING_ERROR_12">InstallScript</span> and bingo, it all worked.<br /><br />Of course there is a catch. This has added a dependency to <span class="blsp-spelling-error" id="SPELLING_ERROR_13">CAPICOM</span>.<span class="blsp-spelling-error" id="SPELLING_ERROR_14">dll</span> to my install. This wouldn't be so horrible except the Microsoft team that created <span class="blsp-spelling-error" id="SPELLING_ERROR_15">CAPICOM</span> obviously doesn't have the first <span class="blsp-spelling-corrected" id="SPELLING_ERROR_16">frigging</span> clue about how Windows Installer works. They seem to think that <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cdb11c8f-36cb-41f6-9ae3-7ba084030877.mspx?mfr=true"><span class="blsp-spelling-error" id="SPELLING_ERROR_17">xcopy</span> to system32 <span class="blsp-spelling-error" id="SPELLING_ERROR_18">regsvr</span>32</a> is the <span class="blsp-spelling-corrected" id="SPELLING_ERROR_19">appropriate</span> way to deploy this <span class="blsp-spelling-error" id="SPELLING_ERROR_20">ActiveX</span> control. There are tons of references that say <span class="blsp-spelling-error" id="SPELLING_ERROR_21">CAPICOM</span> is redistributable but the only <span class="blsp-spelling-error" id="SPELLING_ERROR_22">MSI</span> available is for the entire <span class="blsp-spelling-error" id="SPELLING_ERROR_23">SDK</span>. There is no merge module or <span class="blsp-spelling-error" id="SPELLING_ERROR_24">prereq</span> package containing just the <span class="blsp-spelling-error" id="SPELLING_ERROR_25">ActiveX</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_26">runtime</span> control.<br /><br />So I do some googling and I find an <a href="http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg02835.html">old thread</a> from <span class="blsp-spelling-error" id="SPELLING_ERROR_27">WiX</span>-Users with a good discussion on the component rules and why this is a problem. Finally I stumbled across a <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=924350&SiteID=1">Windows Installer log</a> file that indicates Visual Studio C# Express deploys the file to C:\<span class="blsp-spelling-error" id="SPELLING_ERROR_28">ProgramFiles</span>\<span class="blsp-spelling-error" id="SPELLING_ERROR_29">CommonFiles</span>\Microsoft Shared\<span class="blsp-spelling-error" id="SPELLING_ERROR_30">CAPICOM</span> as <span class="blsp-spelling-error" id="SPELLING_ERROR_31">ComponetID</span> {9504EA7B-206D-4178-8E37-<span class="blsp-spelling-error" id="SPELLING_ERROR_32">EF</span>70<span class="blsp-spelling-error" id="SPELLING_ERROR_33">AE</span>544903},.<br /><br />Ugh, Can we say <span class="blsp-spelling-error" id="SPELLING_ERROR_34">DLL</span> HELL?!?!?<br /><br />Well I suppose since the application I'm deploying targets .NET 3.5 that I could just go ahead and use the x509Store class that's in the .NET <span class="blsp-spelling-error" id="SPELLING_ERROR_35">BCL</span> but 1) I haven't tested that yet and 2) Microsoft employees keep trying to convince me that <a href="http://robmensching.com/blog/archive/2007/04/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres.aspx">managed code custom actions are evil</a> while at the same time they <a href="http://weblogs.asp.net/sweinstein/archive/2004/10/06/238891.aspx"><span class="blsp-spelling-error" id="SPELLING_ERROR_36">compain</span> that other infrastructure <span class="blsp-spelling-error" id="SPELLING_ERROR_37">API's</span> don't target the <span class="blsp-spelling-error" id="SPELLING_ERROR_38">CLR</span></a>. ( Yes, notice even Rob <span class="blsp-spelling-error" id="SPELLING_ERROR_39">Mensching</span> joining in wishing that Windows Error Reporting supported .NET! )<br /><br />Finally I found a <a href="http://www.codeguru.com/Cpp/I-N/internet/security/article.php/c6211">Code Guru project</a> using <span class="blsp-spelling-error" id="SPELLING_ERROR_40">CryptoAPI</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_41">writtten</span> in C++. I tried running the sample <span class="blsp-spelling-error" id="SPELLING_ERROR_42">exe</span> but wouldn't you know it.... it was a debug <span class="blsp-spelling-error" id="SPELLING_ERROR_43">EXE</span> with a dependency on <span class="blsp-spelling-error" id="SPELLING_ERROR_44">MFC</span>42D.<span class="blsp-spelling-error" id="SPELLING_ERROR_45">dll</span>.<br /><br />The <span class="blsp-spelling-error" id="SPELLING_ERROR_46">cryptoAPI</span> example is probably the purist way to go in terms of eliminating the dependency but <span class="blsp-spelling-error" id="SPELLING_ERROR_47">jeesh</span>, it shouldn't have to be this hard. What's 3 lines of script becomes pages of C++.<br /><br />I once mentioned capicom in a previous post and now I know why I get so many hits for it on my statcounter.<br /><br />Someone please slap me and remind me that I actually LIKE setup!Christopher Painterhttp://www.blogger.com/profile/12167478740431444267noreply@blogger.com