<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>matthew-jones.com &#187; Developer</title>
	<atom:link href="http://matthew-jones.com/category/developer/feed/" rel="self" type="application/rss+xml" />
	<link>http://matthew-jones.com</link>
	<description>Ramblings from a developer</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:24:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WiX, MSI Factory, and FinalBuilder</title>
		<link>http://matthew-jones.com/2011/03/wix-msi-factory-and-finalbuilder/</link>
		<comments>http://matthew-jones.com/2011/03/wix-msi-factory-and-finalbuilder/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 13:27:54 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Developer]]></category>

		<guid isPermaLink="false">http://matthew-jones.com/?p=105</guid>
		<description><![CDATA[For some time now, I&#8217;ve struggled to work out how to build the WiX files that are generated by MSI Factory in FinalBuilder and include the bootstrapper. Building WiX files in FinalBuilder is dead easy &#8211; it has actions for the WiX Candle and the WiX linker so you can compile the files that MSI [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>For some time now, I&#8217;ve struggled to work out how to build the WiX files that are generated by <a href="http://www.indigorose.com/products/msi-factory/" target="_blank">MSI Factory</a> in <a href="http://www.finalbuilder.com/" target="_blank">FinalBuilder </a><strong>and include the bootstrapper</strong>. Building WiX files in FinalBuilder is dead easy &#8211; it has actions for the WiX Candle and the WiX linker so you can compile the files that MSI Factory generates (or any other WiX files of course) quite easily. But once you have your MSI, it is nice to have the EXE wrapper for bootstrapping it. Why does this matter? Because if you issue an update to your MSI file, and then double-click to run it, Windows will tell the user they must manually uninstall the app before they can install the update. Not so friendly.</p>
<p>Okay, so what&#8217;s so hard? The bootstrap compiler takes a number of options, and they include the GUIDs that are needed to check if it is installed already. The problem is that you don&#8217;t know the GUID in the build. It turns out that the answer is simple, but it took some time to find, so I&#8217;m blogging it so I remember for next time.</p>
<p>The MSI Factory software comes with a command line tool called &#8220;IRMakeBootstrap.exe&#8221;. This takes an XML configuration file and the name of the output file as parameters, and the product name, but also then needs three parameters that are key to proper operation.</p>
<p>The key ones are -var:PackageCode and -var:ProductCode. Now if you look at your WiX file you will see that it has a line like:</p>
<pre>&lt;Product Id="D03192D5-40A2-4EAC-B1A1-9BACE96AFE78" Name="My App Name" Version="1.0.0" Manufacturer="My Company" UpgradeCode="76D9BEB2-C077-4B7C-A91E-DF294F4C3457" Language="1033"&gt;</pre>
<p>The &#8220;Id&#8221; matches the &#8220;Product Code&#8221; , and the &#8220;UpgradeCode&#8221; matches the Upgrade code, in the Project settings dialog of MSI Factory. However, the PackageCode is not in the file at all. There is a Package node in the XML, but no value. If you look in MSI Factories dialog, there is a &#8220;Package ID&#8221; on the Package tab, but it says &#8220;leave blank to auto-generate&#8221;. But if that is left blank, I can&#8217;t find out what it is to set it to something useful, and thus pass to the bootstrap maker.</p>
<p>Okay, so what is the solution? Simple. Define a GUID in the dialog for the Package ID in the MSI Factory dialog. This is normally a &#8220;bad thing&#8221;, because you want to to change each time (pretty much essential). But you are doing better anyway by using FinalBuilder (or other build tool?) and FinalBuilder is able to generate a GUID just fine. So, set it to a valid GUID string, and then generate the WiX files.</p>
<pre>&lt;Package Id="59D9FCDF-13BE-4AD7-841B-1F11D2E74500" ...
</pre>
<p>You will now find that the XML contains an &#8220;Id&#8221; for the package too. Haha! Now you have what you need to automate it. The value in the XML can now be replaced in your script, and also passed through to the bootstrap builder. Note that the GUIDs passed to the bootstrap builder need the curly brackets surrounding them. This ensures that they match properly.</p>
<p>Finally, you can check that it all works properly by running your install EXE with the &#8220;/Log:c:\install.txt&#8221; parameter which causes it to output a log of its activities.</p>
<p>The final parameters for  the bootstrap maker is:</p>
<p>&nbsp;</p>
<pre>"D:\Src\bootstrap_config.xml" "D:\Src\MySetup.exe" -var:AllowExtractMSI=1 -var:ProductName="Product Name"  -var:PackageCode="{%INST_PACKAGECODE%}"  -var:ProductCode="{%INST_PRODUCTCODE%}" -var:ProductVersion=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_BUILD%</pre>
<div class="shr-publisher-105"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fmatthew-jones.com%2F2011%2F03%2Fwix-msi-factory-and-finalbuilder%2F' data-shr_title='WiX%2C+MSI+Factory%2C+and+FinalBuilder'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fmatthew-jones.com%2F2011%2F03%2Fwix-msi-factory-and-finalbuilder%2F' data-shr_title='WiX%2C+MSI+Factory%2C+and+FinalBuilder'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://matthew-jones.com/2011/03/wix-msi-factory-and-finalbuilder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting code signed</title>
		<link>http://matthew-jones.com/2006/11/getting-code-signed/</link>
		<comments>http://matthew-jones.com/2006/11/getting-code-signed/#comments</comments>
		<pubDate>Wed, 01 Nov 2006 19:54:54 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Code-signing]]></category>

		<guid isPermaLink="false">http://test.matthew-jones.com/?p=25</guid>
		<description><![CDATA[Something that has bothered me for a while is the hassle in putting together all the pieces to sign my download files. I finally got around to looking it all up, and it isn&#8217;t easy as you have to piece all the things together. I hope that this will give you an insight into how [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Something that has bothered me for a while is the hassle in putting together all the pieces to sign my download files. I finally got around to looking it all up, and it isn&#8217;t easy as you have to piece all the things together. I hope that this will give you an insight into how it can really work, since I managed to actually achieve what I wanted and sign my code. This article is a list of the steps I had to take, and you will probably need to review the commands yourself if you have problems.</p>
<table border="0" width="100%" bgcolor="#ccffff">
<tbody>
<tr>
<td>
<h1>Update 2006:</h1>
<p>How things change. Since I wrote this original article, things in             the codesigning world have become a lot easier. I&#8217;ve even renewed             the two year certificate I bought &#8211; but watch out that you get the             renewal from the expiry of the first one or you could lose many days!</p>
<p>The main change though is that Microsoft made the signcode executable             very hard to find, if not impossible. The good news is that there             is a much better option available and, although it isn&#8217;t free, it             is more comprehensive and offers a GUI mode for your initial testing             and a command line option (signcode compatible) for your development             script. The best improvement is that you can specify the password             for the certificate, which means you don&#8217;t have to have the password             dialog pop up all the time. Full details, and links to certificate             suppliers and a step-by-step guide are available from the <span style="font-family: Arial; font-size: x-small;"><a href="http://www.x2net.com/signcode/index.htm" target="_blank">X2Net             SignCode</a></span> web page.</p>
<p>I&#8217;ve left the original article below as it is still a good summary             of the tools that might be useful to people, and how to transform           things.</td>
</tr>
</tbody>
</table>
<h2>The process</h2>
<p>Get a certificate from http://www.ascertia.com/onlineCA/Issuer/CerIssue.aspx who will do a free code signing certificate. Obviously any alternative is good, but this will prove the concept for you, and you can go buy another from them or elsewhere later. The email address is included in the certificate, so use a sensible one you are happy for the world to see. Accept the installation of the certificate into the browser as it won&#8217;t be emailed even though they say it will. Make sure you chose exportable.</p>
<p>Then get the Microsoft code signing stuff (codesigningx86.exe) from the MSDN web site (google will find its current location).</p>
<p>Use the certmgr to view your certificate and export it. Export it as a certificate (.cer file), and with the key (.pvk) file.</p>
<p>Use cert2spc to convert the cer file into an spc file. That&#8217;s the first half of the process done. Now you need a key file compatible with the signcode application.</p>
<p>From http://support.globalsign.net/en/objectsign/transform.cfm:</p>
<table border="0" cellpadding="5" width="100%" bgcolor="#ffffcc">
<tbody>
<tr>
<td>How to transform your certificate to a pvk + spc combination.</p>
<p>Export your certificate to a pfx file <strong>(be sure             to check &#8220;Include all certificates in the certification path             if possible&#8221;)</strong>. (The latter will help ensure it is accepted             by more systems.</p>
<p>Install openssl. You can find compiled binaries on www.openssl.org (but get the Windows build from http://www.shininglightpro.com/ http://www.shininglightpro.com/download/Win32OpenSSL-v0.9.7d.exe)</p>
<p>Extract your private key from the pfx file.</p>
<p>-&gt;openssl pkcs12 -in &lt;pfx-file&gt; -nocerts -nodes -out &lt;pem-key-file&gt;</p>
<p>The pfx password will be asked.</p>
<p>Download the pvk transform utility. This file can be found at http://support.globalsign.net/en/objectsign/PVK.zip.</p>
<p>-&gt; pvk -in &lt;pem-key-file&gt; -topvk -out &lt;pvk-file&gt;</p>
<p>Extract your certificates from the pfx file.</p>
<p>openssl pkcs12 -in &lt;pfx-file&gt; -nokeys -out &lt;pem-certs-file&gt;</p>
<p>The pfx password will be asked.</p>
<p>Transform your pem file to a spc file</p>
<p>-&gt;openssl crl2pkcs7 -nocrl -certfile &lt;pem-certs-file&gt; -outform DER -out &lt;spc-file&gt;</td>
</tr>
</tbody>
</table>
<p>I didn&#8217;t do that last bit &#8211; already did that stage. Note that you are transforming into a PEM file as an intermediate step. I got that bit wrong first time round.</p>
<p>Okay, so now you have all the right bits. You now can just run signcode.exe and use the wizard to check it all works. Select the advanced mode so you can use files, and all should go well. You&#8217;ll have to enter the password at various points. If it all worked, then we are nearly there.</p>
<p>To actually sign the code, and I used <a href="http://www.atozedsoftware.com/finalbuilder/">FinalBuilder</a> to make sure it is done each time and every time reliably, you need the following command.</p>
<table border="0" cellpadding="5" width="100%" bgcolor="#ffffcc">
<tbody>
<tr>
<td>c:\codesigning\signcode -spc &#8220;c:\codesigning\myAscertiaSPC.spc&#8221; -v &#8220;c:\codesigning\myascertiakey.pvk&#8221; -a md5 -i &#8220;www.yourdomain.com&#8221; -n &#8220;Application install file&#8221; &#8220;C:\Build\Installer\yourinstaller.exe&#8221;</td>
</tr>
</tbody>
</table>
<p>If it fails, then you probably got a path wrong or a missing file or something silly. Took me ages to spot that I&#8217;d got an extra letter in a path. Grr.</p>
<p>The only fly in the ointment is that you need to type the password for each file. It&#8217;s not hard to write an app to do the typing for you, but the security of your password is obviously at risk.</p>
<p>An update: Thanks to Hugo Logmans who also provided the script additions to allow <a href="http://www.atozedsoftware.com/finalbuilder/">FinalBuilder</a> to check that it worked okay, which ensures that you don&#8217;t think you signed it.</p>
<table border="0" cellpadding="5" width="100%" bgcolor="#ffffcc">
<tbody>
<tr>
<td>BeforeAction:<br />
CodeSignFailure = true</p>
<p>AfterAction:<br />
ActionResult = NOT CodeSignFailure<br />
Continue = NOT CodeSignFailure</p>
<p>OnStatusMessage:<br />
if InStr(StatusMessage.MessageText,&#8221;Succeeded&#8221;) &gt; 0 then<br />
CodeSignFailure = false<br />
end if</p>
<p>I have this script to sign the program executable AND singlefile<br />
installer-executables. Works very fast and efficient. This way you can be sure the file is always signed.</td>
</tr>
</tbody>
</table>
<p>Update: After some issues that someone identified with the ascertia certificate       on their machine (which I couldn&#8217;t replicate), I bought a two year certificate       from <a href="http://www.instantssl.com/code-signing/">http://www.instantssl.com/code-signing/</a> which       is from a fairly new certificate authority, but is cheap therefore and       is in the XP SP2 root certificates and thus answers the issues.</p>
<p>Update: The codesign executable is a moving target, and is becoming harder       to find. So forget the Microsoft codesign executable, and use one that       is much easier to use and not only command line compatible but more comprehensive.       Give <span style="font-family: Arial; font-size: x-small;"><a href="http://www.x2net.com/signcode/index.htm" target="_blank">X2Net SignCode</a></span> a whirl &#8211; both GUI and       command line options available.</p>
<p><em>Matthew Jones</em></p>
<div class="shr-publisher-25"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fmatthew-jones.com%2F2006%2F11%2Fgetting-code-signed%2F' data-shr_title='Getting+code+signed'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fmatthew-jones.com%2F2006%2F11%2Fgetting-code-signed%2F' data-shr_title='Getting+code+signed'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://matthew-jones.com/2006/11/getting-code-signed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

