<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Wojno: Category How-Tos</title>
    <link>http://christopher.wojno.com/articles/category/how-tos</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Exploration through Code</description>
    <item>
      <title>Creating your own Apache SSL Certificate Signed by your Root CA</title>
      <description>&lt;p&gt;This article is part 2 of &lt;a href="http://christopher.wojno.com/articles/2008/11/04/going-ssl-with-your-own-root-ca"&gt;Going &lt;span class="caps"&gt;SSL&lt;/span&gt; with Your Own Root CA&lt;/a&gt;&lt;/p&gt;


	&lt;h1&gt;Putting your Root CA to work&lt;/h1&gt;


	&lt;p&gt;Now that you have your own Root CA, it doesn&amp;#8217;t do anyone any good unless you use it. You use it by creating certificates for services. The rule is one certificate per-IP address. If you need additional certificates, you should have an IP address for each certificate. Any domain (or sub-domain, etc.) listed in the Certificate&amp;#8217;s CN (Common Name) should resolve to its own unique IP address. Now, nothing is set in stone. But that&amp;#8217;s the way it should be done. I&amp;#8217;ve used multiple certificates for different domains on the same server using Virtual Hosts (same IP) before, but Apache warned me every time I started the server that this is bad practice. If you&amp;#8217;re using Apache, it will still work, but you&amp;#8217;ve been warned (again).&lt;/p&gt;


	&lt;h2&gt;Disclaimers&lt;/h2&gt;


	&lt;p&gt;This guide is for amateur, non-production use only. I make no warranties or guarantees as to the correctness of this document. This guide involves escalating privileges and may cause irreparable damage if used improperly. You use this document at your own risk and I hereby disclaim any responsibility or liability for your actions or non-actions.&lt;/p&gt;


	&lt;h2&gt;Assumptions&lt;/h2&gt;


	&lt;p&gt;I&amp;#8217;m assuming you&amp;#8217;re using Apache 2.X with mod_ssl already installed. I&amp;#8217;m also assuming you&amp;#8217;ve already set-up a vhost file with the site you want to &lt;span class="caps"&gt;SSL&lt;/span&gt; already created and configured minus the specification of the server certificate, and trust chain. I realize this is a lot to assume. &lt;a href="http://tud.at/programm/apache-ssl-win32-howto.php3"&gt;This&lt;/a&gt; can help you setup an Apache server with &lt;span class="caps"&gt;SSL&lt;/span&gt;.&lt;/p&gt;


	&lt;h1&gt;Creating a Server Key&lt;/h1&gt;


	&lt;p&gt;Just as with the Root CA key, you need a server key. Now, if you already have one, relax, skip this step (though I still urge you to create and migrate to the &amp;#8220;secure&amp;#8221; environment created in the next step). You can re-use your server key as many times as you like until you want to upgrade the private key quality (or the key is compromised). If you have &lt;em&gt;not&lt;/em&gt; created a server key, you&amp;#8217;ll need to do so now.&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;ll use OpenSSL again, but first, let&amp;#8217;s create a safe place for our key. The key needs to be readable by the server upon start-up (meaning, the key cannot be encrypted) or Apache (or any other server) will be unable to use it without first asking you for a password. If you don&amp;#8217;t mind typing it in each time, that&amp;#8217;s your prerogative. However, for live or even development environments, it&amp;#8217;s simply impractical.&lt;/p&gt;


	&lt;p&gt;Just as with the Root CA key, you must keep this server key confidential as well. If it is breached, anyone can masquerade as your web server; thus defeating the purpose of the certificate. If you need to move the key, you are advised to use OpenSSL to encrypt it first, however, that is a tutorial for another day.&lt;/p&gt;


	&lt;h2&gt;Create the &amp;#8220;secure&amp;#8221; environment&lt;/h2&gt;


	&lt;p&gt;Create a comfy place for your key. I like to put it in /etc/apache2/ssl with Gentoo, but the better place is likely /usr/local/etc/apache2/ssl and if you use Windows: there are no rules for file placement. With that: create your directory:&lt;/p&gt;


&lt;pre&gt;sudo mkdir /usr/local/etc/apache2
sudo mkdir /usr/local/etc/apache2/ssl
sudo chmod 0770 /usr/local/etc/apache2/ssl
sudo groupadd apache_ssl_admins
sudo chown :apache_ssl_admins /usr/local/etc/apache2/ssl
sudo usermod -a -G apache_ssl_admins YOURUSERNAME # varies by OS&lt;/pre&gt;

	&lt;p&gt;Here&amp;#8217;s what I&amp;#8217;ve done:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Created an apache2 directory (if it didn&amp;#8217;t exist, if this call fails, just make sure the directory is there)&lt;/li&gt;
		&lt;li&gt;Created the &lt;span class="caps"&gt;SSL&lt;/span&gt; directory where we&amp;#8217;ll store the server key&lt;/li&gt;
		&lt;li&gt;Changed the permissions for the directory such that only root can access it&lt;/li&gt;
		&lt;li&gt;Created a group called &amp;#8220;apache_ssl_admins&amp;#8221; &lt;/li&gt;
		&lt;li&gt;Changed the ownership of the new directory to allow members of the apache_ssl_admins access&lt;/li&gt;
		&lt;li&gt;Added you to the new group called &amp;#8220;apache_ssl_admins&amp;#8221;, note that this step may vary among Operating Systems so modify this command as required.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;You&amp;#8217;ll need to log out and log back into your server for the group membership to take effect.&lt;/p&gt;


	&lt;p&gt;Now, I&amp;#8217;ve put the word &amp;#8220;secure&amp;#8221; in quotes as if anyone were to compromise the server and gain access to the apache_ssl_admins group, your key is then accessible. Your key is only as secure as your server.&lt;/p&gt;


	&lt;p&gt;Once you&amp;#8217;ve logged back in, cd to the newly created &amp;#8220;secure&amp;#8221; environment.&lt;/p&gt;


&lt;pre&gt;cd /usr/local/etc/apache2/ssl&lt;/pre&gt;

	&lt;h1&gt;Creating the server key&lt;/h1&gt;


	&lt;p&gt;You will now generate a server key. I highly recommend that you study the &lt;a href="http://www.openssl.org/docs/apps/openssl.html"&gt;documentation&lt;/a&gt; for OpenSSL. It&amp;#8217;s very very rough, but it will help you understand the commands you&amp;#8217;re entering. It may be necessary to update these commands as machines become faster and the encryption level becomes insufficient.&lt;/p&gt;


&lt;pre&gt;openssl genrsa -out www.pem 2048&lt;/pre&gt;

	&lt;p&gt;This generates a new file called www.pem in your &amp;#8220;secure&amp;#8221; environment. This is an &lt;span class="caps"&gt;RSA&lt;/span&gt; private key with a bit length of 2048. This bit-length is considered to be good by today&amp;#8217;s standards. You may use any power of two; though, be warned, larger numbers require more time to initiate &lt;span class="caps"&gt;SSL&lt;/span&gt; connections. Smaller numbers will result in a less secure &lt;span class="caps"&gt;SSL&lt;/span&gt; handshake (and vicariously a less secure &lt;span class="caps"&gt;SSL&lt;/span&gt; session).&lt;/p&gt;


	&lt;p&gt;Again, it is a good idea to encrypt this key with 3des. I&amp;#8217;ve not done so to facilitate this demonstration. Please see the previous tutorial for instructions about encrypting your server&amp;#8217;s private key. The instructions for encrypting your Root CA private key are applicable to this purpose.&lt;/p&gt;


	&lt;h1&gt;Generate a Certificate Signing Request&lt;/h1&gt;


	&lt;p&gt;The Certificate Signing Request (CSR) is used by Root CA&amp;#8217;s to create certificates for people who need them. &lt;span class="caps"&gt;A CSR&lt;/span&gt; is a uniform way to telling Root CA&amp;#8217;s exactly what the certificate should say. The Root CA merely signs the &lt;span class="caps"&gt;CSR&lt;/span&gt; and viola: a certificate. Well, it&amp;#8217;s not all that simple. The Root CA also adds an expiration date to the signature or other fields deemed necessary or desired. But before it can be signed, the &lt;span class="caps"&gt;CSR&lt;/span&gt; must be generated by using the server&amp;#8217;s key:&lt;/p&gt;


&lt;pre&gt;openssl req -new -sha1 -out www.csr -key www.pem&lt;/pre&gt;

	&lt;p&gt;This command will create a file called www.csr in your &amp;#8220;secure&amp;#8221; environment. This file is a Certificate Signing Request. You may expose this file publicly, though that is not required if you&amp;#8217;re signing it yourself. This new request requires that it be identified using the &lt;span class="caps"&gt;SHA1&lt;/span&gt; hashing algorithm. This algorithm is safer than &lt;span class="caps"&gt;MD5&lt;/span&gt; as it has been proven that &lt;span class="caps"&gt;MD5&lt;/span&gt; collisions can be generated in a reasonable time.&lt;/p&gt;


	&lt;p&gt;You will be asked a series of questions after running this command. Answer them honestly. When you see the CN (Common Name), enter the domain name and subdomain for your certificate. I.E. for my domain: christopher.wojno.com, use as the CN: &amp;#8220;christopher.wojno.com&amp;#8221;&lt;/p&gt;


	&lt;h1&gt;Sign your &lt;span class="caps"&gt;CSR&lt;/span&gt; and create a real server Certificate&lt;/h1&gt;


	&lt;p&gt;Now that you have a &lt;span class="caps"&gt;CSR&lt;/span&gt;, we&amp;#8217;ll use our Root CA certificate and key to sign the &lt;span class="caps"&gt;CSR&lt;/span&gt;. This creates a certificate you can use in your Apache server (or other &lt;span class="caps"&gt;SSL&lt;/span&gt;-capable web server). If you created your Root CA using my previous article, then you may use the paths I have specified here. Otherwise, you&amp;#8217;ll need to adjust the -CA, -CAkey and -CAserial parameters to match what you have used.&lt;/p&gt;


&lt;pre style="overflow:scroll;"&gt;openssl x509 -req -days 365 -in www.csr -CA /usr/local/etc/certificate_authority/certs/cacert.crt -CAkey /usr/local/etc/certificate_authority/private/cakey.pem -CAserial /usr/local/etc/certificate_authority/serial.srl -out www.crt&lt;/pre&gt;

	&lt;p&gt;This is a lot to swallow in one step. This used to be where I became completely lost with regard to &lt;span class="caps"&gt;SSL&lt;/span&gt; Certificate generation. The command is very complex so I&amp;#8217;ll break it down part by part:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;We&amp;#8217;re asking OpenSSL to do something&lt;/li&gt;
		&lt;li&gt;Specifically, we&amp;#8217;re asking it to invoke it&amp;#8217;s x509 library (SSL certificate chains)&lt;/li&gt;
		&lt;li&gt;We&amp;#8217;re then specifying that our input will be a &lt;span class="caps"&gt;CSR&lt;/span&gt; (-req)&lt;/li&gt;
		&lt;li&gt;We want the resulting certificate to be valid for 365 days (-days 365) from date of signing&lt;/li&gt;
		&lt;li&gt;The &lt;span class="caps"&gt;CSR&lt;/span&gt; is the input (-in www.csr)&lt;/li&gt;
		&lt;li&gt;We&amp;#8217;re using the CA public certificate created in the previous tutorial: (-CA /usr/local/etc/certificate_authority/certs/cacert.crt)&lt;/li&gt;
		&lt;li&gt;We&amp;#8217;re using the CA&amp;#8217;s private key created in the previous tutorial to sign this &lt;span class="caps"&gt;CSR&lt;/span&gt;: (-CAkey /usr/local/etc/certificate_authority/private/cakey.pem)&lt;/li&gt;
		&lt;li&gt;We&amp;#8217;re using the CA&amp;#8217;s serial file to mark the resulting certificate: (-CAserial /usr/local/etc/certificate_authority/serial.srl)&lt;/li&gt;
		&lt;li&gt;Finally, we&amp;#8217;re outputting a new certificate for the web server: (-out ../www.crt)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;That little command does quite a bit. After running it, you will be prompted for the CA Root private key password (if you created one as I recommended that you do). It should automatically increment the serial file (serial.srl) so that future certificates do not have the same serial number used to identify certificates.&lt;/p&gt;


	&lt;p&gt;Now we have an &lt;span class="caps"&gt;SSL&lt;/span&gt; certificate for your server located in /usr/local/etc/apache2. Time to tell Apache where it is.&lt;/p&gt;


	&lt;h1&gt;Telling Apache about our certificate&lt;/h1&gt;


	&lt;p&gt;This next step takes place in the Virtual Host configuration file (or in your httpd.conf if your OS distro has not broken that file up yet). The true location of this next step can only be described in a universal fashion by describing the purpose: website configuration. Locate that file. In Gentoo, it&amp;#8217;s located at: /etc/apache2/vhosts.d/00_default_ssl_vhost.conf I am unsure as to its location on other operating systems.&lt;/p&gt;


	&lt;p&gt;Once you&amp;#8217;ve located this file, you&amp;#8217;ll need to edit it (this may require privilege escalation). Edit this file in your favorite editor (or least favorite, there is no favorite requirement).&lt;/p&gt;


	&lt;p&gt;Add or amend the following lines in the VirtualHost section of the website you wish to secure using the new &lt;span class="caps"&gt;SSL&lt;/span&gt; Certificate. The hostname of this virtual host must match the CN name you specified when you created the &lt;span class="caps"&gt;CSR&lt;/span&gt; for this site.&lt;/p&gt;


&lt;pre&gt;SSLCertificateFile /usr/local/etc/apache2/ssl/www.crt
SSLCertificateKeyFile /usr/local/etc/apache2/ssl/www.pem
SSLCertificateChainFile /usr/local/certificate_authority/certs/cacert.crt&lt;/pre&gt;

	&lt;p&gt;This tells Apache:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Where our certificate can be accessed so that the server may present it to requesters&lt;/li&gt;
		&lt;li&gt;Where the server&amp;#8217;s private key file is so that the certificate may be used to decrypt encrypted requests from requesters (these requests are encrypted using the certificate in step 1)&lt;/li&gt;
		&lt;li&gt;Where the certificate authority&amp;#8217;s certificate is located so that Apache is able to append it to the certificate presented in step 1 (to avoid having the user&amp;#8217;s browser look it up first)&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Again, I&amp;#8217;m assuming that you&amp;#8217;ve already set up Apache to use &lt;span class="caps"&gt;SSL&lt;/span&gt;:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;You&amp;#8217;ve installed mod_ssl&lt;/li&gt;
		&lt;li&gt;You have enabled it in the /etc/conf.d/apache2 file&lt;/li&gt;
		&lt;li&gt;You&amp;#8217;ve allowed access to port 443 through all firewalls (or other port you wish to use for &lt;span class="caps"&gt;SSL&lt;/span&gt;)&lt;/li&gt;
		&lt;li&gt;You&amp;#8217;ve configured your Apache instance to listen on the &lt;span class="caps"&gt;SSL&lt;/span&gt; port&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;If you&amp;#8217;ve not done so, Apache will not understand the &lt;span class="caps"&gt;SSL&lt;/span&gt; commands and will not start.&lt;/p&gt;


	&lt;p&gt;If all goes well, when you access the website at the CN name on your certificate and use the https protocol (i.e. https://CN where CN is the name used when you were asked for the Common Name when generating the &lt;span class="caps"&gt;CSR&lt;/span&gt;), you will see your website and will not be prompted to accept the authenticity of the certificate. Again, I assume you&amp;#8217;ve completed the previous tutorial and have installed your own Root CA (used to sign this certificate) into your machine&amp;#8217;s trusted Root certificates.&lt;/p&gt;


	&lt;h1&gt;Should something go wrong&lt;/h1&gt;


	&lt;p&gt;Debugging OpenSSL certificate problems is tricky and complicated. OpenSSL provides a tool for doing so over the network. I used it extensively during my first attempts at creating my certificates. Use:&lt;/p&gt;


&lt;pre&gt;openssl s_client -connect CN:PORT -debug&lt;/pre&gt;

	&lt;p&gt;See the &lt;a href="http://www.openssl.org/docs/apps/s_client.html"&gt;documentation&lt;/a&gt;# for more information. Be warned, this is a developer tool and comes with few instructions and brief explanations.&lt;/p&gt;</description>
      <pubDate>Sat, 08 Nov 2008 15:17:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:82d8d7ac-85b3-4b26-8f9c-8143e6478025</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2008/11/08/creating-your-own-apache-ssl-certificate-signed-by-your-root-ca</link>
      <category>How-Tos</category>
      <category>Security</category>
      <category>ssl</category>
      <category>apache2</category>
      <category>ca</category>
      <category>root</category>
      <category>certificate</category>
      <category>tls</category>
      <category>self</category>
      <category>web</category>
      <category>signing</category>
      <category>request</category>
      <category>csr</category>
    </item>
    <item>
      <title>Going SSL with your own Root CA</title>
      <description>&lt;h1&gt;The Prompt&lt;/h1&gt;


	&lt;p&gt;Recently, my slew of &lt;span class="caps"&gt;SSL&lt;/span&gt; certificates expired for my site and e-mail. Like most people, I didn&amp;#8217;t write anything down when I set it up. After all, I was just trying to explore what I could do with my server at that point. So, I decided to make my own Root CA for my site&amp;#8217;s certificates. That way, my family and I can use my root certificate to verify the authenticity of my servers and services.&lt;/p&gt;


	&lt;h1&gt;What are you talking about?&lt;/h1&gt;


	&lt;p&gt;&lt;span class="caps"&gt;SSL&lt;/span&gt; Certificates. &lt;span class="caps"&gt;SSL&lt;/span&gt;/TLS is the secure socket layer. It uses the &lt;span class="caps"&gt;PKI&lt;/span&gt; (public key infrastructure) to provide both data encryption and confidentiality. You can review the Wikipedia article about &lt;a href="http://en.wikipedia.org/wiki/Public_key_infrastructure"&gt;&lt;span class="caps"&gt;PKI&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Transport_Layer_Security" title="now TLS"&gt;&lt;span class="caps"&gt;SSL&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Anywho, with a fully working &lt;span class="caps"&gt;SSL&lt;/span&gt;/TLS system in place, you can be relatively sure that your client-server (and server-server) communications are not only encrypted, but being held between the party with which you believe you are communicating. This means you can use your e-mail and web server on a public network and not worry about your password being sent in the clear or digested format. It also means you&amp;#8217;re sure you&amp;#8217;re talking with your servers and not someone pretending to be a gateway. It&amp;#8217;s nice, but it&amp;#8217;s much more complicated to set up.&lt;/p&gt;


	&lt;p&gt;One of the problems with self-signed certificates is that you are not sure if the certificate is authentic the first time you connect to the server. As I have &lt;span class="caps"&gt;SSL&lt;/span&gt; for my mail and https server, I&amp;#8217;d have to independently verify each certificate via the &lt;span class="caps"&gt;SHA1&lt;/span&gt; hash and identifying information to be absolutely sure my communications are secure.&lt;/p&gt;


	&lt;h2&gt;Where does the Root CA Thingy come in?&lt;/h2&gt;


	&lt;p&gt;&lt;span class="caps"&gt;A CA&lt;/span&gt; is short for &amp;#8220;Certificate Authority.&amp;#8221; A Certificate authority can sign certificates that you make. Because the CA is trusted, when the CA signs your certificate, it transfers that trust to your certificate. When you get your operating system (or your web browser or e-mail client), there are several Root CA&amp;#8217;s pre-installed. They pay lots of cashey money to be there so that your browser, operating system, and e-mail client will recognize theirs and certificates they sign as trusted.&lt;/p&gt;


	&lt;h1&gt;OK, so How do you do it?&lt;/h1&gt;


	&lt;h2&gt;Disclaimers&lt;/h2&gt;


	&lt;p&gt;This guide is for amateur, non-production use only. I make no warranties or guarantees as to the correctness of this document. This guide involves escalating privileges and may cause irreparable damage if used improperly. You use this document at your own risk and I hereby disclaim any responsibility or liability for your actions or non-actions.&lt;/p&gt;


	&lt;h2&gt;Overview&lt;/h2&gt;


	&lt;ol&gt;
	&lt;li&gt;Create a &amp;#8220;proper&amp;#8221; and &amp;#8220;secure&amp;#8221; environment for your CA private key and certificates&lt;/li&gt;
		&lt;li&gt;Create a CA private key&lt;/li&gt;
		&lt;li&gt;Create a CA Certificate Signing Request (CSR)&lt;/li&gt;
		&lt;li&gt;Self-sign the &lt;span class="caps"&gt;CA CSR&lt;/span&gt; using the CA&amp;#8217;s private key thereby creating a CA Certificate&lt;/li&gt;
		&lt;li&gt;Install the CA Certificate locally&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h2&gt;Create a &amp;#8220;proper&amp;#8221; and &amp;#8220;secure&amp;#8221; environment&lt;/h2&gt;


	&lt;p&gt;Before we begin, we need a &amp;#8220;secure&amp;#8221; place to put our CA Root&amp;#8217;s private key. We cannot let this fall into the wrong hands (or any hands other than ours).&lt;/p&gt;


	&lt;p&gt;When you see &lt;span class="caps"&gt;YOURUSERNAME&lt;/span&gt;, replace it with the username you use to access the system onto which you are creating the Root CA&amp;#8217;s certificate.&lt;/p&gt;


&lt;pre&gt;
sudo mkdir /usr/local/etc/certificate_authority
sudo groupadd ca_admins
sudo usermod -a -G ca_admins YOURUSERNAME
cd /usr/local/etc/certificate_authority
sudo mkdir certs
sudo mkdir private
sudo chmod 0770 private
sudo chmod 0775 certs
sudo chown :ca_admins private
sudo chown :ca_admins certs&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll need to log out and then log back in to properly join the ca_admins group. Be sure to cd to the /usr/local/etc/certificate_authority directory when you do so. The following steps assume that you are in that directory.&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;ll be generating the certificate&amp;#8217;s private key. It&amp;#8217;s important that it never be exposed. I highly recommend that you encrypt it now, when it&amp;#8217;s being created, but in this example, I will not do so to facilitate this demonstration. I&amp;#8217;ll indicate where you&amp;#8217;ll need to put in the encryption.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve created an environment that is relatively &amp;#8220;secure.&amp;#8221; That is, it is only as secure as your server. We will generate the private key in the private folder. I have designated this as readable only to root and members of the ca_admins group. I&amp;#8217;ve also put commands in to create that group and have you join it.&lt;/p&gt;


	&lt;p&gt;When you create the CA private key, it will be placed under &amp;#8220;private.&amp;#8221; When the certificate is generated and signed, the resulting certificate will be placed in the certs directory. The only file that needs to be kept secret is the CA private key. We generate it in the next step.&lt;/p&gt;


	&lt;p&gt;The proper location for local configuration changes should be the /usr/local/etc folder. It&amp;#8217;s a toss up as to whether or not a CA&amp;#8217;s private key is a local configuration resource. It may be better to place all of this in the /var/local/certificate_authority. The serial file most assuredly belongs here (created later) as would a Root &lt;span class="caps"&gt;CA CSR&lt;/span&gt; configuration file (not used in this document). However, for the purposes of this document, we&amp;#8217;ll keep it as is.&lt;/p&gt;


	&lt;p&gt;In this step, I&amp;#8217;ve also created a certs directory and a private directory. Certificates that we create for the CA Root should be placed in the certs folder. The private key for the CA Root should be placed in the private directory, as it will not be world-readable.&lt;/p&gt;


	&lt;h2&gt;The CA Private Key&lt;/h2&gt;


	&lt;p&gt;I like &lt;span class="caps"&gt;RSA&lt;/span&gt; certificates, so I generate &lt;span class="caps"&gt;RSA&lt;/span&gt; server private keys.&lt;/p&gt;


&lt;pre&gt;openssl genrsa -out private/cakey.pem 2048&lt;/pre&gt;

	&lt;p&gt;If you want to create an encrypted key, specify this: &lt;pre&gt;openssl genrsa -out private/cakey.pem -des3 2048&lt;/pre&gt; and you&amp;#8217;ll be asked to specify a password for your new key. Do &lt;span class="caps"&gt;NOT&lt;/span&gt; lose this password. You&amp;#8217;ll never be able to get this key back. That means you can&amp;#8217;t sign or create your certificate.&lt;/p&gt;


	&lt;h2&gt;Create a &lt;span class="caps"&gt;CA CSR&lt;/span&gt; and Sign it (single step)&lt;/h2&gt;


&lt;pre&gt;openssl req -new -x509 -key private/cakey.pem -out certs/cacert.crt -days 3600&lt;/pre&gt;

	&lt;p&gt;This creates a 10-year (abouts) certificate signing request that is immediately signed by the CA&amp;#8217;s Root private key to produce the certificate (certs/cacert.crt). We&amp;#8217;ll be using it as our Root CA certificate. If you put a password on the key, you&amp;#8217;ll be asked for that password again. You&amp;#8217;ll also be asked a series of questions to identify your certificate. Answer them honestly. When you get to the CN field, do &lt;span class="caps"&gt;NOT&lt;/span&gt; enter your domain name or similar. Name it something that&amp;#8217;s impossible to be a domain and does not conflict with another Root CA. I called my &amp;#8220;Wojno CA Root&amp;#8221; modeled after Apple&amp;#8217;s certificate name: &amp;#8220;Apple CA Root&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;You now have a real certificate. Now you need to install it locally onto every machine that will use a certificate signed by this Root CA Certificate. Yes, this is bothersome, but it sure beats having to specify an override for every certificate you generate. It also lowers the risk of accepting a bogus certificate by your users, in the event you miss one or more.&lt;/p&gt;


	&lt;h2&gt;Installing the CA Certificate locally&lt;/h2&gt;


	&lt;p&gt;This process varies between operating systems and/or browsers. Apple uses the Keychain. Windows has a root certificate listing in the Internet Options panel (accessible via the control panel). I have no clue where it would be in Vista. You&amp;#8217;re on your own there. Once you have it installed, you&amp;#8217;ll be able to create as many certificates and sign them and all will be automatically trusted because you now trust the Root CA Certificate that will sign them all. Special note: do &lt;span class="caps"&gt;NOT&lt;/span&gt; install stranger root certificates! This will pose a security risk if you go about installing root certificates willy-nilly.&lt;/p&gt;


	&lt;h2&gt;Create the serial file&lt;/h2&gt;


	&lt;p&gt;Back in your ca directory where you created the private and certs folders:&lt;/p&gt;


&lt;pre&gt;echo "01" &amp;gt; serial.srl
sudo chmod 0660 serial.srl
sudo chown :ca_admins serial.srl&lt;/pre&gt;

	&lt;p&gt;Certificates issued by this CA will be imprinted with a serial number. Every time you sign a certificate, the serial file will be incremented and updated. Only ca_admins will be able to modify or read this file. While hiding the contents of this file is not absolutely paramount, the less that is known, the harder it is to break something (this is a generic statement and not necessarily true, but is usually true).&lt;/p&gt;


	&lt;p&gt;For use with Apache2&amp;#8217;s mod_ssl, please see the &lt;a href="http://christopher.wojno.com/articles/2008/11/04/going-ssl-with-your-own-root-ca"&gt;next article&lt;/a&gt; in the series.&lt;/p&gt;</description>
      <pubDate>Tue, 04 Nov 2008 20:06:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:f111918b-6021-481a-96bb-f94751fe3217</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2008/11/04/going-ssl-with-your-own-root-ca</link>
      <category>How-Tos</category>
      <category>Security</category>
      <category>ssl</category>
      <category>ca</category>
      <category>root</category>
      <category>certificate</category>
      <category>tls</category>
      <category>self</category>
    </item>
    <item>
      <title>Rendering Forms in a Paragraph</title>
      <description>&lt;p&gt;Here&amp;#8217;s an example:&lt;/p&gt;


&lt;pre class="code"&gt;
&amp;lt;p&amp;gt;If you're looking for other confidential
search parameters, click
&amp;lt;form action="secret_search" method="post"&amp;gt;
&amp;lt;input type="hidden" value="my secret search parameters"/&amp;gt;
&amp;lt;input type="submit" value="here"/&amp;gt;
&amp;lt;/form&amp;gt;
!&amp;lt;/p&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;You can&amp;#8217;t.&lt;/p&gt;


&lt;Q&gt;The P element represents a paragraph. It cannot contain block-level elements (including P itself).&lt;/Q&gt;
&lt;cite&gt;&lt;a href="http://www.w3.org/TR/REC-html40/struct/text.html#h-9.3.1"&gt;&lt;span class="caps"&gt;HTML4&lt;/span&gt;.0 Reference&lt;/a&gt;&lt;/cite&gt;

	&lt;p&gt;That means you&amp;#8217;re stuck with a line-break if you want to have buttons with form data in your paragraphs.&lt;/p&gt;</description>
      <pubDate>Mon, 14 Jul 2008 12:16:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:09e1209d-6515-4123-a72e-69e6e5a1f634</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2008/07/14/rendering-forms-in-a-paragraph</link>
      <category>How-Tos</category>
      <category>line</category>
      <category>html</category>
      <category>form</category>
      <category>paragraph</category>
      <category>break</category>
    </item>
    <item>
      <title>A DNS Server to Call My Own</title>
      <description>&lt;p&gt;I&amp;#8217;ve been itching to set up my own &lt;span class="caps"&gt;DNS&lt;/span&gt; server for a while now. Why? I&amp;#8217;ve come up with three reasons:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Speed&lt;/li&gt;
		&lt;li&gt;Convenience&lt;/li&gt;
		&lt;li&gt;Security&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;The first one is pure fluff. My home network doesn&amp;#8217;t have nearly enough traffic to make it worth it. The second has merit. It would be nice if I could name machines on the network and have them resolve correctly. I could also use it to mask external addresses. So I could make stuff up and have it resolve locally. So I could make, oh, doubleclick.net resolve to 127.0.0.1. Now, no one on my network will get those advertisements anymore. Sure, I have it set up in the hosts file now, but I&amp;#8217;m like any other network administrator&amp;#8230; No, not lazy, but clever.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m working with Linux Gentoo 2.6.19 here on my local network. There is no chance that I will corrupt any legitimate records as nobody outside my network will be able to query my &lt;span class="caps"&gt;DNS&lt;/span&gt; server. I have my favorite editor: Vim at my side. Named (Bind) is currently at version &lt;span class="caps"&gt;BIND 9&lt;/span&gt;.4.1-P1.&lt;/p&gt;


	&lt;h1&gt;Install bind&lt;/h1&gt;


	&lt;p&gt;First, edit your /etc/portage/packages.use file. Add a line that says:&lt;/p&gt;


&lt;pre&gt;net-dns/bind -ipv6 -ldap postgres -ssl threads -mysql -bind-mysql -odbc&lt;/pre&gt;

	&lt;p&gt;This means: I don&amp;#8217;t want &lt;span class="caps"&gt;IPV6&lt;/span&gt; support (my router doesn&amp;#8217;t support it&amp;#8230; sadly). Don&amp;#8217;t use ldap. Add support for postgres (my favorite database). Don&amp;#8217;t include &lt;span class="caps"&gt;SSL&lt;/span&gt; support (I&amp;#8217;m assuming everyone trusts my server on the local network). Use threads to handle many requests simultaneously (I suppose I could turn this off as the server load will not be very large). Finally, don&amp;#8217;t include mysql bindings or &lt;span class="caps"&gt;ODBC&lt;/span&gt;.  Save that file.&lt;/p&gt;


	&lt;h2&gt;Emerge&lt;/h2&gt;


	&lt;p&gt;Using Gentoo&amp;#8217;s emerge system:&lt;/p&gt;


&lt;pre&gt;%emerge net-dns/bind&lt;/pre&gt;

	&lt;p&gt;It should install without any further intervention.&lt;/p&gt;


	&lt;h2&gt;Firewall (IPTables)&lt;/h2&gt;


	&lt;p&gt;I use the IPTables firewall to protect my server from local and foreign attacks. I like it because it gives me a lot of control over what goes in and out. I also don&amp;#8217;t like it because it is very complicated. If you have a firewall, you need to poke holes in it for port 53 in the following ways:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Outgoing &lt;span class="caps"&gt;UDP&lt;/span&gt; connections TO port 53 from your server to the &lt;span class="caps"&gt;DNS&lt;/span&gt; servers you normally use&lt;/li&gt;
		&lt;li&gt;Incoming &lt;span class="caps"&gt;UDP&lt;/span&gt; connections TO your server on any port from the &lt;span class="caps"&gt;DNS&lt;/span&gt; servers you normally use for established &lt;span class="caps"&gt;UDP&lt;/span&gt; connections&lt;/li&gt;
		&lt;li&gt;Same as #1 with &lt;span class="caps"&gt;TCP&lt;/span&gt; connections&lt;/li&gt;
		&lt;li&gt;Same as #2 with &lt;span class="caps"&gt;TCP&lt;/span&gt; connections&lt;/li&gt;
		&lt;li&gt;Incoming &lt;span class="caps"&gt;UDP&lt;/span&gt; connections from the local network on port 53&lt;/li&gt;
		&lt;li&gt;Outgoing &lt;span class="caps"&gt;UDP&lt;/span&gt; connections to the local network on any port for established &lt;span class="caps"&gt;UDP&lt;/span&gt; connections&lt;/li&gt;
		&lt;li&gt;Same as #5 with &lt;span class="caps"&gt;TCP&lt;/span&gt; connections&lt;/li&gt;
		&lt;li&gt;Same as #6 with &lt;span class="caps"&gt;TCP&lt;/span&gt; connections&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;The above table is derrived from nixCraft&amp;#8217;s article: &lt;a href="http://www.cyberciti.biz/tips/linux-iptables-12-how-to-block-or-open-dnsbind-service-port-53.html"&gt;Linux Iptables block or open &lt;span class="caps"&gt;DNS&lt;/span&gt; / bind service port 53&lt;/a&gt; I added some modifications, however. Here&amp;#8217;s an example configuration:&lt;/p&gt;


	&lt;h3&gt;firewall.sh&lt;/h3&gt;


&lt;pre&gt;#!/bin/bash
IPTABLES='/sbin/iptables'
LOCALNET='--src-range 192.168.1.2-192.168.1.254'
INTIF1='eth0'
DNSSERVERS='a.b.c.d a.b.c.e' # 2 IP addresses for your ISP's DNS servers

# PREAMBLE
$IPTABLES -F #flush old rules
$IPTABLES -X #clear old chains
$IPTABLES -A INPUT -s 127.0.0.1 -j ACCEPT #always trust requests from the server
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT #always trust active connections

# ... (other rules here)

# BIND/NAMED
# Outgoing Recursive Requests
for ip in $DNSSERVERS
do
        iptables -A OUTPUT -p udp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
        iptables -A INPUT -i $INTIF1 -s $ip -p udp --dport 53 -m state --state ESTABLISHED -j ACCEPT
        iptables -A OUTPUT -p tcp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
done
# incoming request configuration
# accept local queries
iptables -A INPUT -i $INTIF1 -m iprange $LOCALNET -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT

# block out all other Internet access
$IPTABLES -A INPUT -j DROP&lt;/pre&gt;

	&lt;p&gt;The for loop was nixCraft&amp;#8217;s idea. Very clever, however, instead of using the IP address of the server, I fell back to the interface card. Then, no matter what your IP address, you&amp;#8217;ll be able to control access to the &lt;span class="caps"&gt;DNS&lt;/span&gt; server.&lt;/p&gt;


	&lt;p&gt;Update your firewall rules by executing your firewall script.&lt;pre&gt;%./firewall.sh&lt;/pre&gt;&lt;/p&gt;


	&lt;h2&gt;IPTables example explained&lt;/h2&gt;


	&lt;p&gt;This example actually works as is. But if you&amp;#8217;re using &lt;span class="caps"&gt;SSH&lt;/span&gt; for access, you need to add in an &lt;span class="caps"&gt;SSH&lt;/span&gt; hole: &lt;pre&gt;$IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Now, the beginning of the script defines (in order) the script used to interpret the file (#!/bin/bash), the iptables program (stored as a variable for ease in name or location changes), &lt;span class="caps"&gt;LOCALNET&lt;/span&gt; (an IP address range specifying your local network, generally, 192.168.1.1 is the gate way and packets may appear to originate from your router if it&amp;#8217;s a piece of junk. 192.168.1.255 is broadcast, so no need to include that address either), &lt;span class="caps"&gt;INTIF1&lt;/span&gt; is the &lt;span class="caps"&gt;NIC&lt;/span&gt; card on my server. Use ifconfig to figure out what yours is (or iwconfig if you have a wireless server because you&amp;#8217;re crazy that way). Next, I define the &lt;span class="caps"&gt;DNS&lt;/span&gt; servers from my &lt;span class="caps"&gt;ISP&lt;/span&gt;. I didn&amp;#8217;t list them here because my &lt;span class="caps"&gt;ISP&lt;/span&gt; probably would not appreciate that. Use &lt;a href="http://www.opendns.com"&gt;OpenDNS&lt;/a&gt; if you&amp;#8217;re really in a bind (pun not intended).&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s skip to the #BIND/NAMED section. Here, I&amp;#8217;ve looped through each &lt;span class="caps"&gt;DNS&lt;/span&gt; server from my &lt;span class="caps"&gt;ISP&lt;/span&gt;. I&amp;#8217;ve opened up the &lt;span class="caps"&gt;UPD&lt;/span&gt; and &lt;span class="caps"&gt;TCP&lt;/span&gt; ports to allow recursive look ups generated by my local network traffic. After that loop, I open up port 53 locally. Notice I&amp;#8217;ve used the interface (-i #INTIF1). This restricts where requests may originate. You really only need this if you have more than one &lt;span class="caps"&gt;NIC&lt;/span&gt; card on the box.&lt;/p&gt;


	&lt;h1&gt;Configuration&lt;/h1&gt;


	&lt;p&gt;Before we can test, there&amp;#8217;s one more thing we need to do: configure named/bind to listen to us. By default, bind is configured to only accept connections made &lt;span class="caps"&gt;ON THE SERVER&lt;/span&gt;. That doesn&amp;#8217;t help when you want other computers on your network to be able to make requests. Open: /etc/bind/named.conf in vim. You need to change the listen-on directive to include your local network address. I just used &amp;#8220;any&amp;#8221; as my firewall will deny any other requests.&lt;/p&gt;


&lt;pre&gt;...
options {
  /* ... other configurations here ... */
  listen-on {any;};
};&lt;/pre&gt;

	&lt;p&gt;Make sure you include the semi-colon after &amp;#8220;any&amp;#8221; or you&amp;#8217;ll get named complaining at you. Restart named (bind). &lt;pre&gt;%sudo /etc/init.d/named restart&lt;/pre&gt;&lt;/p&gt;


	&lt;h1&gt;Testing your server&lt;/h1&gt;


	&lt;p&gt;You should now be able to test &lt;span class="caps"&gt;DNS&lt;/span&gt; lookups from another machine. From you local (non-DNS server), type:&lt;pre&gt;%dig @DNSSERVER_IP_ADDRESS www.google.com&lt;/pre&gt; Replace &lt;span class="caps"&gt;DNSSERVER&lt;/span&gt;_IP_ADDRESS with the IP address of the server on which you just configured and installed bind/named. You should get something similar:&lt;pre&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.4.1-P1 &amp;lt;&amp;lt;&amp;gt;&amp;gt; @DNSSERVER_IP_ADDRESS www.google.com -t A
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 13465
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 7, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.            IN    A

;; ANSWER SECTION:
www.google.com.        604748    IN    CNAME    www.l.google.com.
www.l.google.com.    249    IN    A    64.233.169.104
www.l.google.com.    249    IN    A    64.233.169.103
www.l.google.com.    249    IN    A    64.233.169.147
www.l.google.com.    249    IN    A    64.233.169.99&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re using Windows, you need to use nslookup (command line application). The syntax is slightly different. If you&amp;#8217;re using Gentoo, you need to first install the bind tools (emerge net-dns/bind-tools).&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it! You now have a working local &lt;span class="caps"&gt;DNS&lt;/span&gt; server merely acting as a cache.&lt;/p&gt;</description>
      <pubDate>Sun, 30 Dec 2007 15:56:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:7ea47163-4315-4fa6-9f05-bbb30b030215</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/12/30/a-dns-server-to-call-my-own</link>
      <category>How-Tos</category>
      <category>bind</category>
      <category>dns</category>
      <category>named</category>
      <category>setup</category>
      <category>cache</category>
      <category>install</category>
      <category>configure</category>
      <category>gentoo</category>
      <category>linux</category>
      <category>server</category>
    </item>
    <item>
      <title>Mac Latex-mk</title>
      <description>&lt;p&gt;I really like the LaTeX typesetting system. It makes nice looking documents. It&amp;#8217;s a bit of a pain to use, however. On FreeBSD, there is a &lt;span class="caps"&gt;LIFE&lt;/span&gt;-SAVING port called &amp;#8220;latex-mk,&amp;#8221; which is a set of &lt;em&gt;maintained&lt;/em&gt; make files that will do all the heavy-lifting for you. It&amp;#8217;s only released for FreeBSD and NetBSD, but I&amp;#8217;ll walk you through how to install it on Darwin (Mac). I make no warrantees here. You accept all responsibility for following these instructions or deviating from these instructions. I am not responsible for lost data or damaged property, etc.&lt;/p&gt;


	&lt;h1&gt;Installation&lt;/h1&gt;


	&lt;h2&gt;Getting LaTeX and latex-mk&lt;/h2&gt;


	&lt;p&gt;First, you need the latex package for Mac: &lt;a href="http://tug.org/mactex/"&gt;MacTex&lt;/a&gt;. Install that the usual way (or read their instructions if you get lost, no sense me repeating them). Once you have that installed, grab the &lt;a href="http://latex-mk.sourceforge.net/"&gt;latex-mk&lt;/a&gt; file. You&amp;#8217;ll have to dig around a big, look under &amp;#8220;Obtaining&amp;#8221; if that link still exists. You&amp;#8217;ll see a SourceForge download. Download this file:      latex-mk-1.9.1.tar.gz. I&amp;#8217;m sure these instructions will work for future versions too, though I make no guarantees.&lt;/p&gt;


	&lt;h2&gt;Uncompressing/Unarchiving&lt;/h2&gt;


	&lt;p&gt;Go ahead and unzip the latex-mk. Crack open a terminal (Finder &amp;gt; Applications &amp;gt; Utilities &amp;gt; Terminal.app). Change to the latex-mk directory:&lt;/p&gt;


&lt;pre&gt;cd ~/Downloads/latex-mk-1.9.1&lt;/pre&gt;

	&lt;p&gt;If the version has changed, cd to that. Remember, you must unzip it first. Apple&amp;#8217;s archiver should handle it. But you can always do a &amp;#8220;tar -xzf latex-mk-1.9.1.tar.gz&amp;#8221; if you&amp;#8217;re old fashioned like me.&lt;/p&gt;


	&lt;h2&gt;Configuration&lt;/h2&gt;


	&lt;p&gt;Like most packages, you need to run the configuration program. Do this from the latex-mk-1.9.1 directory (you should still be there).&lt;/p&gt;


&lt;pre&gt;sh ./configure&lt;/pre&gt;

	&lt;p&gt;You will see lots of text fly by. If you get errors, sorry, this tutorial is over. Drop me a line, maybe I&amp;#8217;ll be able to help or point you in the right direction. If you see it create lots of little files, then you&amp;#8217;re golden.&lt;/p&gt;


	&lt;h2&gt;Compile&lt;/h2&gt;


	&lt;p&gt;Type:&lt;/p&gt;


&lt;pre&gt;make&lt;/pre&gt;

	&lt;p&gt;And, after a very short time, it will complete.&lt;/p&gt;


	&lt;h2&gt;Install&lt;/h2&gt;


	&lt;p&gt;Type&lt;/p&gt;


&lt;pre&gt;sudo make install&lt;/pre&gt;

	&lt;p&gt;Sudo will ask for an administrator&amp;#8217;s password. Enter it. If you don&amp;#8217;t trust this package, you can always install by hand&amp;#8230; But I&amp;#8217;m not going over that. Once this is done, latex-mk is now installed and ready for use.&lt;/p&gt;


	&lt;h2&gt;Cleaning up&lt;/h2&gt;


	&lt;p&gt;Type:&lt;/p&gt;


&lt;pre&gt;make clean distclean&lt;/pre&gt;

	&lt;p&gt;That will remove any installation files. You may also simply delete the latex-mk-1.9.1 folder. You should delete the zip file from which you got the latex-mk-1.9.1 folder; you no longer need it.&lt;/p&gt;


	&lt;h3&gt;Testing&lt;/h3&gt;


	&lt;p&gt;Let&amp;#8217;s take it for a spin. Assuming you have MacTex installed already:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Create a new folder somewhere, I&amp;#8217;ll call it: &amp;#8220;Test&amp;#8221; &lt;/li&gt;
		&lt;li&gt;cd to &amp;#8220;Test&amp;#8221; &lt;/li&gt;
		&lt;li&gt;Create a new latex document, say, &amp;#8220;test.tex&amp;#8221; and type or copy in the following:&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;%test.tex:
\documentclass[]{article}
\begin{document}
\LaTeX
\end{document}
&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;Now create a new file called &amp;#8220;Makefile&amp;#8221; and put the following into it:&lt;/li&gt;&lt;/ul&gt;

&lt;pre&gt;#Makefile
NAME = test
TEXSRCS = test.tex
BIBTEXSRCS = 
TGIFDIRS = tgif_figs

include /usr/local/share/latex-mk/latex.gmk
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;At the command prompt, type: &amp;#8220;make pdf&amp;#8221;&lt;/li&gt;
&lt;li&gt;You&amp;#8217;ll see it build the file. When it finishes, open finder and go to your &amp;#8220;Test&amp;#8221; folder. You&amp;#8217;ll see a shiny new &amp;#8220;Test.pdf&amp;#8221; so go ahead, click it! You&amp;#8217;ll see the strangely formatted LaTeX logo.&lt;/li&gt;
&lt;/ul&gt;

	&lt;p&gt;Congratulations. You just &amp;#8220;ported&amp;#8221; a FreeBSD application to Mac. Aren&amp;#8217;t command line applications grand?&lt;/p&gt;


	&lt;h1&gt;Why Latex-mk?&lt;/h1&gt;


	&lt;p&gt;Latex-mk takes care of lots of details when creating LaTeX documents. It keeps your bibliography up to date automatically and will re-run the latex processor to ensure all your citations and cross references are up to date and shiny. Otherwise, you have to run latex 2-3 time every change to ensure your references will be linked. Your new friend is &amp;#8220;make pdf&amp;#8221; as it enables one-stop generation shopping.&lt;/p&gt;


	&lt;h2&gt;More Information&lt;/h2&gt;


	&lt;p&gt;The make file can do much more. You should see what it can do by going to the &lt;a href="http://latex-mk.sourceforge.net"&gt;latex-mk site&lt;/a&gt; for instructions.&lt;/p&gt;</description>
      <pubDate>Sun, 30 Dec 2007 11:27:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:4edcce25-e0eb-4085-9e32-59bc7c43b6d0</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/12/30/mac-latex-mk</link>
      <category>How-Tos</category>
      <category>freebsd</category>
      <category>port</category>
      <category>mac</category>
      <category>latex</category>
      <category>makefile</category>
      <category>mk</category>
    </item>
    <item>
      <title>Mac Applications Not (Force) Quitting</title>
      <description>&lt;p&gt;I&amp;#8217;ve just recently (a few hours ago) run into applications not loading or quitting (even with Forced quits) on Mac &lt;span class="caps"&gt;OSX10&lt;/span&gt;.5 Leopard on a brand-new machine. Here&amp;#8217;s the grueling story:&lt;/p&gt;


	&lt;p&gt;I tried to read a .doc and I declined to try Office 2004 for Mac. Nothing appears wrong at this point. I then tried to launch iTunes, it had the launched icon (blue circle) under it, leading me to believe it was running, but there was no window. I could not interact with iTunes at this point. I attempted repeatedly to launch iTunes to no avail. So, I did what any self-respecting &lt;span class="caps"&gt;GUI&lt;/span&gt; user did: Quit. After ignoring the problem report, I attempted the last straw, the Force Quit. After trying that several times, also to no avail, I turned to the Internet for help. Most forums suggested unplugging your iPod when this happens. I do not have an iPod attached to the computer. So I tried a little Unix magic. But &amp;#8220;kill -9&amp;#8221; from the command line was ineffective. Trevor suggested &amp;#8220;killall Dock,&amp;#8221; (the &lt;a href="http://docs.info.apple.com/article.html?artnum=304728"&gt;Dock&lt;/a&gt; is the application &amp;#8220;Task Bar&amp;#8221; for you Windows users) but that was also ineffective. iTunes appeared thusly in ps xau:&lt;/p&gt;


&lt;pre&gt;% ps xau | grep iTunes
6432   0.0  0.0        0      0   ??   E    6:45PM   0:00.00 (iTunes)&lt;/pre&gt;

	&lt;p&gt;I&amp;#8217;ve never seen an &amp;#8220;E&amp;#8221; state before, nor a process enclosed in parenthesis. According to the man pages for ps, the &amp;#8220;E&amp;#8221; means &amp;#8220;the process is trying to exit.&amp;#8221; The man pages, however, are silent as to what (PROCESS &lt;span class="caps"&gt;NAME&lt;/span&gt;) means.&lt;/p&gt;


	&lt;h1&gt;Can&amp;#8217;t Quit, Can&amp;#8217;t Delete&lt;/h1&gt;


	&lt;p&gt;&lt;a href="http://www.apple.com/macosx/features/timemachine.html"&gt;Time Machine&lt;/a&gt; is running and was backing files up at that time to  an external &lt;span class="caps"&gt;USB&lt;/span&gt; disk. It also refused to load or force quit (like iTunes) after stopping the back up. I could also not view the trash as it claimed that items were &amp;#8220;being deleted.&amp;#8221; The system was still responsive (I could browse the Internet to look for forums with this problem, but found nothing completely applicable). I attempted to restart: &lt;span class="caps"&gt;APPLE MENU&lt;/span&gt; &amp;gt; Restart. All windows quit, but the system would not complete the restart. After trying to restart &lt;span class="caps"&gt;AGAIN&lt;/span&gt; (the dock was still visible, so I opened up a Terminal and the menu reappeared), iTunes, System Preferences (Time Machine) and trash were still inaccessible. I then forced a restart by holding down the power button.&lt;/p&gt;


	&lt;h2&gt;Office 2004 for Mac not the problem&lt;/h2&gt;


	&lt;p&gt;Now, convinced Office was the problem, to avoid this problem again I attempted to deinstall the Office 2000 Test Drive application(s). That began to run, it claimed to have progressed 1/10th of the way through (as seen by the progress bar) at which point, the application was hung. Force quit was ineffective. I submitted a problem report about Remove Office crashing. But the application persists! Force quitting that does not shut it down either. Things are getting serious.&lt;/p&gt;


	&lt;h1&gt;Time machine&lt;/h1&gt;


	&lt;p&gt;Time Machine was not actively backing up at this time. I decided to unmount the back up drive &amp;#8220;Time Machine Backups&amp;#8221; (what Time Machine calls its backup drive). This did nothing as well. The drive refused to unmount, even though backups were stopped (this was done via System Preferences &amp;gt; Time Machine and then click the circled X near &amp;#8220;Backing up&amp;#8221; or &amp;#8220;Next Backup&amp;#8221;. Since that didn&amp;#8217;t work, I decided to go for the gusto. I yanked the &lt;span class="caps"&gt;USB&lt;/span&gt; cable to the backup drive. This caused the trash to immediately empty. Remove Office quit. It appears that Time Machine is causing these hangs.&lt;/p&gt;


	&lt;h2&gt;The External Drive&lt;/h2&gt;


	&lt;p&gt;The external hard drive is a Smart Disk, 60GB FireLite XPress.&lt;/p&gt;


	&lt;p&gt;I then decided to check the disk. I launched the disk utility (Applications&amp;gt;Utilities&amp;gt;Disk Utility.app) and ran &amp;#8220;Verify Disk&amp;#8221;. It claims that the drive appears to be OK. I repaired it anyway and after a vigorous re-indexing (thank you Spotlight (AKA &amp;#8220;mdworker&amp;#8221; to ps)) the volume, again, appears to be OK. Things appear to be working again. I&amp;#8217;ll try yanking the cable if it misbehaves again.&lt;/p&gt;


	&lt;h1&gt;Problem&lt;/h1&gt;


	&lt;p&gt;Applications not quitting, even after forced quit&lt;/p&gt;


	&lt;h1&gt;Solution&lt;/h1&gt;


	&lt;p&gt;Unplug external hard drives/iPods connected via &lt;span class="caps"&gt;USB&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;Although it appears that Time Machine may be responsible, it may apply to all external &lt;span class="caps"&gt;USB&lt;/span&gt; hard drive devices.&lt;/p&gt;</description>
      <pubDate>Fri, 28 Dec 2007 21:24:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:c60ca314-725b-49ee-808e-5d43198fc135</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/12/28/mac-applications-not-force-quitting</link>
      <category>How-Tos</category>
      <category>time</category>
      <category>problem</category>
      <category>mac</category>
      <category>force</category>
      <category>usb</category>
      <category>quit</category>
      <category>application</category>
      <category>machine</category>
      <category>hard</category>
      <category>drive</category>
    </item>
    <item>
      <title>Thunderbird Copy to Sent IMAP Connection Error</title>
      <description>&lt;p&gt;This article applies to: &lt;a href="http://www.mozilla.com/en-US/thunderbird/"&gt;Thunderbird&lt;/a&gt; v.2.0.0.9 and a few previous versions and may very well be applicable in the future.&lt;/p&gt;


	&lt;h1&gt;The Solution&lt;/h1&gt;


	&lt;p&gt;I&amp;#8217;m assuming you want the solution and not the explanation. If you really do want the explanation, scroll down and come back!&lt;/p&gt;


	&lt;p&gt;After I set up my own &lt;span class="caps"&gt;IMAP&lt;/span&gt; server for my e-mail, I began to get error messages from Thunderbird: &amp;#8220;Error copying message to sent folder. Retry? OK.&amp;#8221; Rather than change my Postfix server (which was advised against by the documentation), I looked for a client-side solution. Retrying is a crap-shoot. Sometimes it copies, but most of the time it just sits there after informing you that:&lt;/p&gt;


&lt;blockquote&gt;Unable to connect to your &lt;span class="caps"&gt;IMAP&lt;/span&gt; server. You may have exceeded the maximum number of connections to this server. If so, use the Advanced &lt;span class="caps"&gt;IMAP&lt;/span&gt; Server Settings Dialog to reduce the number of cached connections.&lt;/blockquote&gt;

	&lt;p&gt;Advanced &lt;span class="caps"&gt;IMAP&lt;/span&gt; Server Settings Dialog? I&amp;#8217;ve never heard of that before. Let&amp;#8217;s see what about:config has to say. You can find it in Tools-&amp;gt;Options&amp;#8230; on Windows, or Edit-&amp;gt;Options&amp;#8230; on other platforms. Once you see the dialog, hit the &amp;#8220;Advanced&amp;#8221; icon at the top right, then hit the &amp;#8220;General&amp;#8221; tab in the area below it. You&amp;#8217;ll see &amp;#8220;Config Editor&amp;#8230;&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;I tried setting: mail.imap.max_cached_connections from 5, to 1, to 0. No value fixes it.&lt;/p&gt;


	&lt;p&gt;I then noticed: mail.server.server2.max_cached_connections And not just that one (I have several &lt;span class="caps"&gt;IMAP&lt;/span&gt; accounts). There were a few others as well. Setting these to 1 &lt;span class="caps"&gt;HAS&lt;/span&gt; solved my problem.&lt;/p&gt;


	&lt;p&gt;Just make sure all your: mail.server.server&lt;strong&gt;N&lt;/strong&gt;.max_cached_connections = 1&lt;/p&gt;


	&lt;p&gt;Now, had I listened to the error message from the start, I would have gone to the account settings for each. Right click on the &lt;span class="caps"&gt;IMAP&lt;/span&gt; account and select properties. Then goes to server settings. You&amp;#8217;ll notice an &amp;#8220;Advanced&amp;#8221; button. Sure enough, you see the text field for the number of cached connections. Of course, if you want to change them all at once, you can use the Config Editor.&lt;/p&gt;


	&lt;p&gt;Remember, restart Thunderbird for the changes to take effect. Don&amp;#8217;t expect miracles until after you&amp;#8217;ve relaunched.&lt;/p&gt;


	&lt;h1&gt;The Explanation&lt;/h1&gt;


	&lt;p&gt;&lt;span class="caps"&gt;IMAP&lt;/span&gt; connection caching? Yes, when Thunderbird checks your e-mail over &lt;span class="caps"&gt;IMAP&lt;/span&gt;, it starts up a &lt;span class="caps"&gt;TCP&lt;/span&gt; connection. That&amp;#8217;s a 3-way handshake.&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Hello Server!&lt;/li&gt;
		&lt;li&gt;Hello Client!&lt;/li&gt;
		&lt;li&gt;Hello again Server! (I got your hello)&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;3 Hello&amp;#8217;s = 3 way handshake. &lt;span class="caps"&gt;OK OK&lt;/span&gt;, yes, this is a gross oversimplification. None-the-less, this handshake sequence is considered slow and &amp;#8220;expensive.&amp;#8221; So instead of saying good-bye after getting your mail, the client will say, &amp;#8220;I&amp;#8217;ll be back, so leave the line open.&amp;#8221; Sounds good, but most servers have limited resources. Once the maximum number of connections is reached, it won&amp;#8217;t accept any more. That&amp;#8217;s what is happening with Thunderbird here. It&amp;#8217;s being told that there is no more room.&lt;/p&gt;


	&lt;p&gt;So, what limited resource am I talking about? Well, those connections take up memory, especially the secure ones. &lt;span class="caps"&gt;SSL&lt;/span&gt; adds the overhead of a new shared secret (passphrase). That&amp;#8217;s not too bad, but it&amp;#8217;s more than storing the usual, unencrypted nothing. Even if you don&amp;#8217;t use &lt;span class="caps"&gt;SSL&lt;/span&gt;, each connection uses a new port. Every computer has 65535 ports. Depending on the system, approximately 1000 of them are reserved for system calls. The other 64,000 and change are shared among all the services provided by the server. And, yup, you guessed it, each connection uses up a port.&lt;/p&gt;


	&lt;p&gt;May not seem like a big deal. But say, you have an account. Thunderbird caches 5 connections by default. If you have 5 folders, it will use all 5 connections and cache them. If your e-mail is on a dedicated machine: 64,535/5 = 12,907. Only 13 thousand users can check their mail (if they all have 5 or more folders). If you have a big company, this would be bad if the &lt;span class="caps"&gt;CEO&lt;/span&gt; or &lt;span class="caps"&gt;POB&lt;/span&gt; (pointy haired boss) can&amp;#8217;t check his or her e-mail. Most servers will limit you (as did mine and probably yours if you&amp;#8217;re reading this article to solve your problem) to 4 connections from the same IP address. While it helps solve the connection volume problem, Thunderbird gets confused.&lt;/p&gt;


	&lt;p&gt;See, if you need a new connection on the same account, thunderbird will use any active ones. But if you have multiple accounts, Thunderbird assumes the connections are independent. Apparently, this is a mistake.&lt;/p&gt;


	&lt;h2&gt;An Expert Fix&lt;/h2&gt;


	&lt;p&gt;I suggest that Thunderbird take note of refused connections and give up active connections from &lt;em&gt;other&lt;/em&gt; accounts if they resolve to the same server. That will expand the already automatic connection cycling feature among connections on the same account to connections on the same client.&lt;/p&gt;</description>
      <pubDate>Thu, 20 Dec 2007 21:46:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:a5e3237a-f6ab-4a62-9064-c50cb15600f3</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/12/20/thunderbird-copy-to-sent-imap-connection-error</link>
      <category>How-Tos</category>
      <category>thunderbird</category>
      <category>imap</category>
      <category>cached</category>
      <category>connection</category>
      <category>exceed</category>
      <category>fix</category>
    </item>
    <item>
      <title>UPE (Zeta) Freshman Unix Talk</title>
      <description>&lt;p&gt;&lt;span class="caps"&gt;UPE&lt;/span&gt; wanted to hold a Freshman Unix Talk to introduce new students to &lt;span class="caps"&gt;USC&lt;/span&gt;&amp;#8217;s shared computing resources. It is to help them understand the system so they can program their assignments with it and not pull out their hair in the process. Naturally, I jumped at the opportunity to give the talk.&lt;/p&gt;


	&lt;p&gt;It is an overview of Unix as an operating system from the user&amp;#8217;s perspective. So I&amp;#8217;ve included some charts of commonly used programs.&lt;/p&gt;


	&lt;p&gt;I gave this talk a few months back and had forgotten to post it here.&lt;/p&gt;


	&lt;p&gt;You&amp;#8217;re free to use it so long as I remain credited and you don&amp;#8217;t make any money from it.&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/unixtalk.pdf"&gt;Freshman Unix Talk&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 13 Dec 2007 12:51:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:22c3d84c-86d3-48d8-872c-db5ec53af44b</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/12/13/upe-zeta-freshman-unix-talk</link>
      <category>How-Tos</category>
      <category>Operating Systems</category>
      <category>unix</category>
      <category>upe</category>
      <category>talk</category>
      <category>freshman</category>
      <category>guide</category>
      <category>cheatsheet</category>
      <enclosure type="application/download" url="http://christopher.wojno.com/files/unixtalk.pdf" length="374775"/>
    </item>
    <item>
      <title>X11R6-R7 Upgrade Problem: elf_load_section: truncated ELF file</title>
      <description>&lt;h1&gt;The Problem&lt;/h1&gt;


	&lt;p&gt;I attempted to update &lt;span class="caps"&gt;X11&lt;/span&gt; from &lt;span class="caps"&gt;X11R6&lt;/span&gt;.7 to &lt;span class="caps"&gt;X11R7&lt;/span&gt;.3 about a month ago. However, I was not successful and after getting this cryptic message when running startxfce4:&lt;/p&gt;


&lt;pre&gt;elf_load_section: truncated ELF file
Abort&lt;/pre&gt;

	&lt;p&gt;Launching startx yields that same message repeated six times. Oddly enough, launching X worked and also had two truncated &lt;span class="caps"&gt;ELF&lt;/span&gt; files (or the same one repeated). So, X worked, despite the inability to read a few files. I was confounded to say the least.&lt;/p&gt;


	&lt;p&gt;I spent hours, which lead to days trying to find what &lt;span class="caps"&gt;ELF&lt;/span&gt; file was truncated. Google searches and digging through help forums turned up nothing. I did:&lt;/p&gt;


&lt;pre&gt;pkg_delete -rx ".*xorg.*" 
pkg_delete -rx ".*font-.*"&lt;/pre&gt;

	&lt;p&gt;(deleted everything xorg and that which depended on it), then reinstalled xorg (/usr/ports/x11/xorg) to no avail. I even updated from FreeBSD-6.1-RELEASE to FreeBSD-6.2-RELEASE.&lt;/p&gt;


	&lt;p&gt;As of today, I have resolved the problem and I almost lost my mind when I discovered that xinit, a critical component of startx (startx is invoked by startxfce4), was not even installed. Keep in mind, I was getting this error before I deinstalled everything, so I did not deinstall it inadventently and send myself on a wild goose chase.&lt;/p&gt;


	&lt;p&gt;I assume the port maintainers moved this component out of the xorg port for some reason when they went from &lt;span class="caps"&gt;X11R6&lt;/span&gt;.9 to R7.2. Indeed, the &lt;a href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/x11/xinit/distinfo"&gt;dist file&lt;/a&gt; for the port xinit supports that conjecture.&lt;/p&gt;


	&lt;h1&gt;In Summary&lt;/h1&gt;


	&lt;p&gt;Simply &lt;span class="caps"&gt;INSTALL&lt;/span&gt;: /usr/ports/x11/xinit and you&amp;#8217;ll be able to use &lt;span class="caps"&gt;X11&lt;/span&gt; again. You need not deleted everything. Oh, please be sure you updated according to the /usr/ports/UPDATING file&amp;#8217;s directions. &lt;span class="caps"&gt;X11&lt;/span&gt; upgrades have always required special treatment (this one&amp;#8217;s no different).&lt;/p&gt;


	&lt;p&gt;Best of luck to you.&lt;/p&gt;</description>
      <pubDate>Sat, 17 Nov 2007 21:09:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:4a596106-27c5-43de-bcbf-578c6754c13b</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/11/17/x11r6-r7-upgrade-problem-elf_load_section-truncated-elf-file</link>
      <category>How-Tos</category>
      <category>freebsd</category>
      <category>file</category>
      <category>ELF</category>
      <category>truncated</category>
      <category>xinit</category>
      <category>X11</category>
      <category>update</category>
      <category>port</category>
    </item>
  </channel>
</rss>
