Just found this fantastic video explaining the Diffie-Hellman key exchange.
What a great idea to use the colors-methaphor to explain the basic concept.
Just found this fantastic video explaining the Diffie-Hellman key exchange.
What a great idea to use the colors-methaphor to explain the basic concept.
A few months ago I created an Ember.js video-tutorial. Some people were happy with it, which means I helped them to learn Ember.js. And this in turn, makes me happy.
So, because I had time today, I decided to create another one of these tutorials. This time it’s about the best web-development framework in the world, Java Server Pages.
I’m kidding. Of course it’s about Ruby on Rails.
Here is the video (click on link below for HD-link):
Click here to watch on Vimeo (HiDef-Version)
The code for the demo-application is hosted at Github.
I apologzie for the poor sound quality. I think you can still understand me though, so I didn’t record everything a second time.
Also, in the beginning I say I want to finish in 30 minutes. It’s almost twice the time.. Well, I had fun.
The NSA-story is making headlines. That is a good thing. While it may not immediately change things for the better, it’s important that these issues are in the minds of the people so we can all reflect on them. Because they are important.
They probably matter more to people like programmers. (As Paul Graham pointed out somewhere: The personality traits that make a good programmer seem to be the same personality traits that make one question authority.) But ultimately, as we are heading for a highly technological future with interconnected devices becoming part of our daily routines, these issues matter to everyone. And will increasingly continue to do so.
First things first, though.
Yes, Edward Snowden should be considered a hero. He not only stood up for what he believed is right - at the cost of probably throwing away any chance of having a normal life for himself. He also raised a hand and spoke up in advocacy for something that is a very important cornerstone of a democracy. The ability for the people to check on what their government is doing and, like a referee, being able to call a foul-play.
And since democracy, at least in my view, is a very important achievement of human civilization, any energy invested in upholding it, is energy well spent. That includes what Mr. Snowden did. That includes the media reporting on it. And that includes the time spent by everyone thinking about these things. In order to answer a few questions for themselves.
For example:
And so forth.. Everyone can ask his or her own questions and try to come up with answers.
Since I am a programmer I can say something about the technological aspect of it. If we wanted to secure our data today, could we even do it? Well, let’s just take email as an example.
It should be known by now that sending an email is like sending a postcard. Everyone involved in the delivery of an email message (this includes a dozen computers owned by different organizations) can simply read that message.
Fortunately there’s a remedy for that: Encryption.[4]
Encrypting an email is a method to make sure that only the recipient of the message will be able to read its contents. That’s the equivalent of putting the letter in an envelope.
But the problem is: It’s almost impossible to do for the average person, because it simply is too complicated. You have to concern yourself with the basics of cryptography and install software that, at this point in time, still isn’t very intuitive to use.
The solution, of course, is to build products, let’s say an email client, that do provide encryption and are easy to use. (It’s not too difficult to imagine such a product.) We could have encrypted emails and most users wouldn’t even have to worry about it. It would just be, well, secure.
But would it?
Ultimately, the problem with security is that you have to trust someone. Simply because you cannot verify everything yourself. That is an impossible task.
And I am not even talking about understanding encryption alorithms (which, on a sidenote, aren’t that complicated). I am talking about the software and hardware your secure email is running on.
In the end, the security of encryption is based on keeping your (private) key secret. But if others have full access to your computer (= they can read files on it), they can steal your key and then your security is out the window.
How exactly would you know that the company that wrote the email software is not sharing your key clandestinely? How would you know your Operating System isn’t doing the same thing? Or how about the company that build your mobile phone? [5]
The answer is that, in practice, you really can’t. [6]
So far there has been “soft protection” in the sense that a deterrent for companies to spy on us has exited on the grounds that if they got caught, it would be bad for their business.
But if the state is passing sercret laws that force companies to spy on customers and then lie about it the protection is gone.
Meaning that we neither can have protection by technology, nor do we have protecton by business motives and/or protection by reputation.
So what is left?
In the end, the initiative must be directed at lawmakers. It must be directed at politicians. It must be ensured that these issues are at the core of the values in a democratic system.
We must have governments where each branch of it is accountable for its actions to some other entity. And where the checking-powers are, in fact, exercised. [7] Transparently.
In my view the problem is similar to the problem of corruption. It is very damaging to countries (from individual welfare to the economy as a whole), and very difficult to get rid of.
But, just like the surveillance state, corruption must be fought against. A battle at a time. Because the consequences can be truly horrible.
I encourage everyone to study the history of former soviet countries. Read books by George Orwell. Look at new democracies like Poland, Romania, Croatia. See what problems they are dealing with or have dealt with since the end of the iron curtain. Learn what it takes to become a democratic state in the sense of the EU. What independence means. What freedom means. Why the founders of the United States of America agreed on that constitution and not a different one.
Look at what is at stake here. Help to shape politics that make it difficult and illegal for the government to break important rules that justify and make up the basis for our civilizational achievements.
Edward Snowden sparked a very imporant debate. For that I want to thank him.
And now it’s time to look at America. I hope the Americans will kick some ass now. Because some asses truly deserve to be kicked. Right out of their chairs.
Notes:
[1] On Prism, partisanship and propaganda - The Guardian
[2] Should the government know less than Google? - The Economist
[3] The Lives of Others trailer - YouTube
[4] Encrypt Your Email With GPG
[5] He who smelt it, dealt it. Remember how the US government complained about the sale of Huawei phones in the USA? Because the Chinese could spy on Americans? How ironic, but not really suprising, that they would say that. Isn’t it. ;)
[6] That is a benefit of open source software though.
[7] A quick review of US government strucure
Stumbled over this poem reading Slashdot:
The Circle of Knowledge
All philosophy is anthropology;
All anthropology is psychology;
All psychology is biology;
All biology is chemistry;
All chemistry is physics;
All physics is math;
All math is philosophy. :-)
Written by Paul Fernhout.
It’s possible to authenticate a user on a website using client certificates instead of a username and a password. The webserver, in my case Apache, uses a server certificate and only clients with the correct client certificate are able to connect to it.
Last night, for an experiment, I’ve created such a setup on OS X 10.8.4 Mountain Lion using the Apache that is pre-installed on OS X.
To save others some headache, here’s the walkthrough on how to go about it. Please keep in mind that I am not an Apache2 config expert or an ssl-guru. There’s probably room for improvement in the configuration files and process listed below.
Make sure you check out the link I’ve pasted at the very bottom of this article. It was a huge help to make this work!
So let’s get to work.
For me this was a minimal Rails app that is serving a static webpage. In my case I was using thin
and I’ve just started it listening to port 9090.
The default Apache on OSX has its config files in the folder /etc/apache2/
which in fact is /private/etc/apache2
. It has a subfolder users
that has configs for each user on the system. So in my case, I edited /etc/apache2/users/lukas.conf
.
This just means that every connection that comes in on port :443 will be forwarded to port :9090. Replace :443 with :80 and restart Apache and you should be able to see the app from Step 1. when typing http://localhost
in your browser.
To restart apache you can type
Now, because we said “SSL Only” in the task description, we have to ensure that only SSL connections are accepted. So here’s what my lukas.conf
looks like if we do that:
The config mentions two files, web.crt
and web.key
. It’s time to create those.
Note: If this doesn’t work, then take a look at the apache config in /etc/apache2/httpd.conf
and ensure that the Proxy and SSL modules are being loaded. (That the appropriate lines are not commented out.)
I think a CA (and all certs) can be created using the keychain tool that is included in OS X. However, I prefer the command line approach with openssl. It also has the nice side-effect that the guide will be (mostly) valid on a Linux-machine.
I’ve created two directories, /etc/apache2/certs/
and /etc/apache2/certs/ca
. And then I’ve used the shell script from here to create the CA. I’ve pasted the contents into create_ca.sh
in /etc/apache2/certs
.
As you can see, it (amongst other files) creates the ca.conf
in /etc/apache2/certs/ca
with the contents of everything between the two occurrences of EOF
. Afterwards it creates a key, a signing request, and finally the singing certificate ca.crt
in the ca
-folder.
So now just run this shell script with bash create_ca.sh
.
It will ask you to enter details for your CSR. Make sure you enter localhost
when it asks for the FQDN. (Or your domain should you be following these steps for anything else than localhost.) Whatever it is, it should match what you have entered in the apache config as ServerName
.
When it’s done make sure you open /etc/apache2/certs/ca/ca.conf
and replace the string REPLACE_LATER
with /etc/apache2/certs/ca
.
Voila, we have our own GoDaddy now. Just a pity that no browser in the world, not even our own, will trust our certificates!
Let’s move on.
We need two certificates. The before mentioned web.crt and a client.crt that will be imported into the OS X-keychain so the browsers can access it.
Creating a certificate is straightforward. Here are the basic steps:
So first let’s create the server certs (these will have passphrases that you must type and remember):
When you now restart Apache it will ask for the passphrase. You should also be now able to connect to https://localhost
in your browser. (Your browser will display an ugly, scary warning that you can ignore since it’s just your local box and you won’t scare away any users..)
Okay, now let’s create the client certificate. The one our browser will have to show to get access to the webapp.
For the CN you can enter your own name, since the certificate is issued for you, the user that wants to access the webapp.
Finally, let’s convert the cert to pkcs#12.
It may ask for an export password. You will need it when you (or the user you issued this for) later import the cert into the keychain.
Before we move on to the last step, let me just mention that the whole CA-business doesn’t have to be in a subfolder of your apache config. It can be on a completely different machine. It’s just a few files that help with issuing certificates and they haven’t got anything to do with Apache. It’s in this folder here for convenience (you would only need the ca.crt file in this setup, btw.), but I would probably put them in an entirely different (and very safe) place if I for example was GoDaddy..
Now the grand finale:
Back to the Apache config! We have to tell Apache to disconnect everyone with an SSL-error that doesn’t present the right client certificate.
Restart apache. You should no longer be able to connect to https://localhost
.
In order to be able to connect again you must import the client certificate into the keychain.
Simply open client.p12
and keychain should automatically open and ask you to import the key. Now refresh your browser, you should be able to connect.
Finally, especially in case of any problems, don’t miss this post on garex.net. It’s a fantastic guide on how to make this work and I would probably still be scratching my head if it wasn’t for this text.
I am currently having a good time programming an iOS app at my current project. While searching for information about a certain topic I’ve stumbled over NSHipster, written by Matt Thompson. The tagline reads: “NSHipster is a journal of the overlooked bits in Objective-C and Cocoa. Updated weekly.”
There’s great content there that I am recommending for every Objective-C programmer. In fact, I am putting it on my Bookmarks-page.
In the 1970s two authors created a box of cards called “Oblique Strategies”. [1] They are supposed to help creative people (musicians) to break creative blocks. It works like this: You get stuck. You pull out a card from the box and ponder it’s meaning which hopefully will help you resolve your problem.
The suggestions are sometimes cryptic. But many suggest a change of perspective. [2] This is useful. Perhaps it is a good idea to start developing our own sets of cards, as well.
There is a website that will randomly give you one card from the original decks. [3] Try it out or read the whole list extracted from that website’s HTML:
(Organic) machinery
A line has two sides
Here’s a good read: “Learning Javascript Design Patterns” by Addy Osmani.
Couldn’t sleep last night, so I coded up a little web-app to get tired. It’s a simple chat that works with websockets with Rails and the websocket-rails gem.
It’s really not much, but if you want to see how to write such a thing, check out the Github repository.
There’s software I’d like to have written. For example, a port of the Zenburn colorscheme [1] for Octopress. Or a real time map-matching algorithm in Ruby.[2] Or an up to date guide on securing a Linux webserver. And many things more.
I could of course sit down and tackle these problems one by one myself. But I’d run out of time. After all I have work for clients, my personal projects and everything that makes up my private life. So can’t others write it?
The open source software world is full of great things. Not just nice-to-have gimmicks, but truly essential software that often generates great value for startups and established companies. The days of Oracle and Microsoft licenses for libraries and developer tools are over. At least in the Web and mobile application world. [3]
But how much more could be developed and released for free if there was a way for open source devs to make a living from their contributions?
Sure, some do. An open source database can be financed by selling premium services such as hosting, teaching and tech-support. But many things, some small, but still significant, are made by individuals in their free time.
And then there’s Kickstarter.com which is spearheading a paradigm shift in how projects of all sizes can be financed online. Wouldn’t it be cool to have a site like this exclusively for open source software and related things? [4]
Let’s imagine how a site like this could work.
First, people could post requests of things they want to have developed. For example: “A streaming-webradio library written in Objective-C for use with iOS 6”.
Other people (and companies) could now vote to either express “Yes, I/we need this, too.” or they could agree it’s a worthwhile pursuit and say “Yes, and I am willing to pay 50USD to a developer who writes the software.”
At the same time developers could write responses like: “I can do this. It will take me one month and I want to be paid X dollars for it. I will develop it in this fashion: […insert implementation details here…]”
The idea is to not start a website where the cheapest developer wins, but rather someone who can layout his implementation idea and, possibly, back it up with references, such as his Github repository.
The users can then select which developer should be awarded the job. [5] After a developer is selected, a kickstarter-esque funding round begins. If the amount of Dollars is reached, the money is charged and put into escrow.
The money should be given to the developer in parts, for example as a weekly salary. Meanwhile others should be able to review his work. (And even join in to help him or her.)
If the project looks like it’s a failure it can be stopped, and the remaining funds can be transferred back to the backers. If it succeeds, the last payment goes to the developer.
The software (finished or not) is then released under an Open Source license.
I don’t know.. Perhaps this is a silly idea for many reasons I haven’t thought of. But I think it would be neat thing to have if it worked. Companies would of course benefit as well, and they would have the chance to help finance projects directly and get things that mean profit for their business in return.
Footnotes:
[1] Zenburn colorscheme
[2] This is something I work on for a side-project. The link is to my question on gis.stackexchange.com
[3] Okay, I guess you still need vendor specific libraries, if you develop for any phone platform. I just wanted to make a point that Open Source software changed where we get our tools and libraries from.
[4] Kickstarter.com - There might be many others. I should take some time to research similar sites..
[5] Instead of chosing an individual developer a team could be selected, as well. This team could even change in the future and money to individuals is given proportinately to their involvement.