My favourite Ruby (on Rails) Books

I’ve read a couple of Ruby and Ruby on Rails books now and for those who wonder which book is right for them, I want to give recommendations.

Ruby Books:

My favourite ruby book is the “The Ruby Programming Language” from O’Reillys shelf. It is written by David Flanagan (author of Javascript, The Definitive Guide) and Matz himself. This book is like a Definitive Guide but its not as heavy as the Javascript version as it is “only” 430 pages thick.
The big benefit of this book is that it covers all the new stuff from Ruby 1.9. I also like that it completely leaves out any kind of tutorial like part. It’s really all you need to know. Well written and reference like.

My second favourite book is from Addison Wesley and its called “The Ruby Way”. With 888 Pages this is even more like the definitive guide but there are some minor things that I don’t like about this book. So minor I won’t even mention them. If I had to chose between the O’Reilly book and this one I’d choose both.

The third book I can recommend is the Pragmatic book. This one is more for beginners as it starts with a tutorial that gives you a somewhat playful insight into the world of ruby. But once you’ve read this book and want to know more you will put this book aside and consider the previously mentioned ones.

Rails Books:

Same here. I’d highly recommend the Addison Wesley book “The Rails Way” because it is more like a reference to Rails and covers each aspect with way more details than the famous Pragmatic book which again starts with a tutorial that takes up half of the book. Its a very good and easy start for early Rails developers but it leaves so many questions open that you will definitly need another one. In this case – take the Addison Wesley one.

One of my ideas became reality – without me: Port of the Processing language to JavaScript and Canvas

A couple of semesters ago, when i was still enrolled ad UdK I’ve had the idea of porting processing to javascript. I wanted to use SVG instead of canvas but at that time canvas wasn’t really that big. I’ve never had the time to pursue that idea because I was busy with lots of other things but today I’ve read on that someone had the same idea and actually realized it. See here:

Port of the Processing language to JavaScript and Canvas

The results also look pretty cool – not sure if I would’ve been able to get it to this level. Thumbs up for another project that uses web technologies completely out of their initial scope of use cases.

Updates, really

I haven’t forgotten my weblog. It’s just that if you have lots of stuff to blog about, you don’t really have time to do it. At least that’s the case here.

On monday for example, I booted my very first computer. I was kind of late though so its a pretty decent machine compared to what most of my friends had. It’s a Apple Macintosh Performa 6200 with a stunning, Pentium smoking 75 MHz PowerPC, 24MB Ram and 500 MB HDD. I got this thing 1995 I believe, so it’s 13 years old and it was running almost every day since because my dad was still using it after I got a new computer. He used Filmaker 3.0 for writing bills and keeping track of customers. He ran it until last monday when I was at my parents and thought that it might be a good idea to finally transfer all his sensible data to another machine. The HDD would fail some day and I wanted to prevent an emergency call. But there was a problem. This machine had almost no useful interfaces to retrieve the data. There’s no USB, no Firewire, no Ethernet – nothing! It has a SCSI connector but I don’t have any SCSI capable machines anymore. So I took my computer to the CCCB in order to remove the HDD and plug it into a new machine. The Performa 6200 was one of the first Macs which got an IDE HDD instead of SCSI. I was hoping that I could simply put it into an old G4 desktop in order to copy the files. It turned out though, that at the time they shipped the Performa, Apple was formatting the HDDs in their factory in a special way. This was changed late but appearently my disk was special because no modern computer I connected it to was able or willing to show me the files. Meanwhile I was thinking that I might destroyed the filesystem by putting it in the G4.

I didn’t bring the 15″ screen, the ADB Mouse and Keyboard with me, so I couldn’t boot it. After I got the missing pieces from my parents I connected everything and my Mac booted as it used to be:

My first Computer

It was like christmas. Or my birthday when I got my Mac. I went through all my files, played F/A 18 Hornet 2.0, Cyclone II and Rescue and was smiling all over my face.

Then I connected my old Syquest EZ 135 Drive with 135 MB cartriges via the SCSI port to backup my dads files. A friend then retrieved the files via his old mac which had a 10 MBit ethernet port. Now Filemaker 9 Pro was even able to convert the 3.0 database files and everything went through successfully. Now I can keep my first computer and play F/A 18 Hornet with it.

By the way, if someone out there really wants to make me happy – buy me this game: http://www.graphsim.com/games-fa18-oif.html

After all these emotions I have to say that this computer still looks nice on my desktop. Imagine a 13 years old PC box! The Performa case is well designed. Doesn’t look like it is that old. I can even connect a TFT display so everything looks real crisp.

The machine never had any problems. The battery faded out but it can be replaced. It was really worth the money.

Flickr

Flickr works as a community. You upload photos, people find them and ask you if they can use them. You get feedback without advertising them or something like that.

Sometimes however people use your pictures without letting you know. This happens of course when you attach a proper license to your photos. This happened to one of my 24c3 photos. The german newspaper »Die Zeit« used this one on their website in this article.

I think flickr is amazing in many aspects as it is one of the few web communities that are useful.

24c3 bcc

Creating your own CA – The Miracles of OpenSSL

Currently I’m digging myself into the world of administrating servers. I started with webservers but by now I’m administrating multiple servers that run services like DNS, HTTP, Mail, SVN, MySQL, PostgreSQL and a couple more. My last thing was DNS. I’ve read through the reference book from O’Reilly: DNS & Bind and set up two authoritative and one public DNS server.

Now that I’ve set up all this stuff I need to dig into the next thing. I wanted my fellow students and the professors at my university to use secure connections when they would log into their mail accounts, weblogs and wikis. Therefor I would have to deploy certificates. Since the administrators of my university were unable to create proper certificates I decided to create a CA on my own. So I started reading a bunch of tutorials about HTTPS and OpenSSL. None of these were really satisfying as they would only go for a quick fix. »Create a CA, create certificates, configure apache, don’t care about the details.« – That is what most of the tutorials were like. If I would go as far as creating my own CA for our faculty I wanted to make it as good as I possibly could. Therefor I started reading even more tutorials and howtos just to find out that almost everybody is doing it differently. There wasn’t the definitive guide I was hoping for. Then I got the Secure Networking with OpenSSL book from O’Reilly which had yet another approach. Even a friend of mine, who is earning tons of money deploying PKI for large corporations, couldn’t answer all my questions. In the end I came up with my own solution which is a mixture of the OpenSSL book and the expertise of my friend.

It goes like this:

First of all, if you really want to save you a lot of pain, create your own custom openssl.cnf. If it is setup properly you’ll save you a lot of typing and get a lot more consistency automatically. The book, in contrast to most tutorials, starts by creating a directory for all your certificates and keys.

> mkdir /usr/local/etc/ssl
> cd /usr/local/etc/ssl
> mkdir crl				#for cert revocation lists
> mkdir	certs				#this is where new certs go
> mkdir private				#this is where the key go
> touch index.txt			#file to keep track of your certs
> echo 01 > serial			#file to keep track of the serials

Thats gives you the basic structure. Of course you should set the proper permissions to prevent access from others. Your private CA key should be really private. Once obtained you can start all over again and worry about your security nightmares becoming true.

Now lets get to the openssl.cnf file. On FreeBSD edit vi /etc/ssl/openssl.cnf.
The default openssl.cnf is very long and not that easy to understand when you look at it for the first time. I won’t explain everything to you, instead this is a guide for people who want to create their own CA and are willing to read through the book, the man pages or the tutorials which I will also post at the end.

The most important part to understand the openssl.cnf is probably the [ foo ] syntax. It works like this:

default_ca = CA_default

In this case you’re saying the default_ca is defined beneath the secttion CA_default.
The section itself is defined beneath [ CA_default ] and it goes until the next [ section ] definition

# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
extensions              = certificate_extensions

####################################################################
[ ca ]
default_ca      = CA_default            # The default ca section

####################################################################

[ CA_default ]

dir             = /usr/local/etc/ssl    # Where everything is kept
certs           = $dir/certs            # Where the issued certs are kept
crl_dir         = $dir/crl              # Where the issued crl are kept
database        = $dir/index.txt        # database index file.
#unique_subject = no                    # Set to 'no' to allow creation of
                                        # several ctificates with same subject.
new_certs_dir   = $dir/certs            # default place for new certs.

certificate     = $dir/cacert.crt	# The CA certificate
serial          = $dir/serial           # The current serial number
crlnumber       = $dir/crlnumber        # the current crl number
                                        # must be commented out to leave a V1 CRL
crl             = $dir/crl.pem          # The current CRL
private_key     = $dir/private/cacert.key# The private key
RANDFILE        = $dir/private/.rand    # private random number file

x509_extensions = certificate_extensions# The extentions to add to the cert

default_days    = 720                   # how long to certify for
default_crl_days= 10                    # how long before next CRL
default_md      = sha1                  # which md to use.
preserve        = no                    # keep passed DN ordering

policy          = policy_match

# For the CA policy
[ policy_match ]
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = supplied
commonName              = supplied
emailAddress            = optional

This part defines the location auf the ssl directory and all the other files. It also defines the section for the x509 extensions. In my configuration they look like this:

[ certificate_extensions ]

# These extensions are added when 'ca' signs a request.

basicConstraints=CA:FALSE

# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer

# Copy subject details
issuerAltName			= issuer:copy

keyUsage                        = digitalSignature,keyEncipherment

extendedKeyUsage                = serverAuth,clientAuth

crlDistributionPoints           = URI:http://yourdomain.com/crl

nsCaPolicyUrl                   = URI:http://yourdomain.com/policy

This is actually the part where my friend helped me out. Most of the quick fix tutorials leave out the x509 extensions which are crucial for a serious CA and certificates as they give the the potential clients further information about the key usage, the policy and the revocation lists. It doesn’t provide more security but more seriousness and it is a lot better than a certificate which has no real information at all (e.g. Some Organization, Some City, Some Stat).

You can view the rest of my openssl.conf by clicking on this link. Take a look at the x509 extensions in particular as some of them are not in the default config file.

After you set up your openssl.cnf its time to get started creating your CA.
Issue the following command. This will create a CA key/cert pair. Also note that the CA certificate belongs into ssl/cacert.crt. You can change this in you openssl.cnf though.

Step 1:

openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem

Enter all the details you want to have in your certificates. Thats it, you have now a self signed CA. Now continue by creating a new key and a certificate signing request by tying:

Step 2:

openssl req -newkey rsa:1024 -keyout testkey.key -keyform PEM -out testreq.csr

Note that the bitlength of 1024 is recommended for HTTPS as many clients / browsers do not support higher values. I don’t know if this is still valid. If you tried out or know by fact that all current browsers support higher values, let me know! Since this certificate is for a browser and you want it to work with older browsers too you specify 1024 bit. Now you can sign this certificate signing request with your CA certificate.

Step 3:

openssl ca -in testreq.csr

You will now be promted with the certificate request information and the question whether to sign it. After confirming the request a new serial is written to the ssl/serial file and the hash of the new cert will be appended to index.txt. Your new cert is created in ssl/certs/.

Now you can continue creating new certificates under your new CA by repeating step 2 and 3.

To complete this post I’m going to list all the webpages I consulted for help and that had indeed useful information (I’m skipping the quickfix ones):

So in the end this seems like a quick fix tutorial as well. It is indeed but I think this one works really well and provides you with a proper openssl.cnf as well as some useful links. Again – read the book and manpages as you will probably discover some more details about PKI in general. I hope this post was any help for you.