Thursday, September 19, 2013

Small Side Project

The other day, while on lunch, I decided to write a quick bash script to determine the IP of my machine.   For the first incarnation of this script, I chose Bash as it is just a quick and dirty way to achieve my goal.  
Well, after working on it for a little bit on my Linux machine, I looked to my right and saw my Macbook sitting next to me.  Being a *nix backed OS, I decided that the script also needed to support it, as well.  What the heck, why not throw Solaris into the bunch as well, seeing as I also have access to a Solaris machine.
Once I decided to take a break, I created a new repo up on Github to host the project, created a license and readme file and got my script checked into the repo.  Shortly after I put up a facebook post about the new repo, a colleague downloaded it, tested it and quickly posted a suggestion for improvement.  
I will be the first to admit that my initial design was a bit short-sighted and didn't take into account interfaces that were not active.  
I quickly went about a re-design to determine which interface(s) were active, and report their IP's.  After getting the script working as hoped on Mac, I turned my attention to Linux and Solaris.  I quickly realized that when dealing with servers, you will most likely have multiple active interfaces, including virtual (vnet) interfaes. 
Sitting here writing this, I think I may simply report each one, and also print the interface name in the output, which is currently not done.  The code is a work in progress, so if you are interested, please stay tuned and watch the updates flow.  
As always, if you have any suggestions for script improvement or if you find any bugs, please open an issue through the project on Github.  

Thursday, September 05, 2013

Effing ARGH!!!!!

Let me just say how painful it is when you have been pouring tons of time into a pet project that you feel strongly about, and that you had a "grand plan" for, only to literally stumble upon another site that has already implemented the idea.  ARGH!!!!!

My idea was to be a nutritional information site.  It would cover not only standard foods and processed foods from your grocery store, but also the food at restaurants.  I wanted this thing to be the one-stop-shop for anyone conscious about their health and what they eat.  

One of the main reasons this is near and dear to me is that I am a Diabetic, and earlier this year changed my entire eating style to be Paleo.  Its been an amazing journey thus far and I wanted this site to be the nutritional information bible.

Well, while downloading restaurant nutritional information last night, I noticed that one of the PDF's was not hosted at the restaurant's site, but instead another site all together.  I went to the root url only to discover that this site, where the info was hosted, already provided what my site was going to provide.  And on top of that, it was pretty slick.  A friend suggested I use their data as my source and make a better site, but to be honest, it wouldn't be right.  Yes, I am one of those honest people and believe in doing the right thing.

You can say 'C'est la vie'..... move on..... whatever you choose, but it doens't take the sting out of the fact that I feel robbed and completely screwed over having been totally beaten to the fully implemented concept.  

I am going to just have to ensure that the next idea that I have gets to fruition quicker, before someone else does it.

Monday, September 02, 2013

Do My SSL Keys Match Up?

Recently, at my day job, we had an issue where the SSL certificate that we had in place for one of our URL's, was expiring and needed renewing.  One of my colleagues had renewed the certificate, but did not have time to install it immediately.  So, the day that its expiring we had to do a bit of scrambling to get it replaced on the server.

So, having been given this task, I logged on to the server and noticed that the public key, signing keys and private keys were all put into the same directory.  Cool, I don't have to figure out where to put them.  So, I downloaded the certificate bundle from our issuer and unzipped it.  It was then that I realized that the bundle only contained the public key and the signing certificate(s).  

So here I am, with the new key and no private key.  Plus, looking on our issuer's site, there was no way to tell what private key was used.  Thus became my quick search of the Googles to determine how to compare a public key with a private key to see if they are a pair.  

If you have manually created SSL certificates before, then you should already (hopefully) be familiar with the openssl software.  Thankfully, that software can also be used to pair up public and private keys.

In order to match up two keys, you need get some output from the keys themselves.  On the public key, you want to run the following:

openssl x509 -noout -text -in cert.crt
You will then want to run the following on the private key that you suspect may match up:

openssl rsa -noout -text -in cert.key
As part of the output of both of those commands you will see a section called "Modulus", which looks something like this:

Modulus (4096 bit):

What is really nice is that if they are the correct pair, the modulus of both keys will be identical.  To finish my anecdote regarding work, I got lucky and the first key that I chose (which was the private key previously used), ended up being a match, proving that they new key was generated using it by our provider.  

I hope this has helped someone find their long lost matching keys.  
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.