Monthly Archives: June 2011

How to trust a certificate in Java on Mac OS X

Yesterday, Apple released an update to Java for OS X.  I had trusted a self-signed cert with my old java installation, and it stopped working with the update, so I had to figure out how to add it again.  It’s not very hard, but kind of tricky to figure out, so here you have it.

First, export the cert using a web browser or whatever.  I used firefox, because it is easy, and I couldn’t figure out how to do it in chrome.  You should end up with a simple PEM encoded file.  Then here’s how you import it:

$ cd /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security
$ sudo cp cacerts cacerts.orig
$ sudo keytool -importcert -file your_cert_file_here -keystore cacerts

you’ll be prompted to trust it, then you are done.

Update:
In recent versions of OS X (at least 10.9 and 10.10), you can use this command to find your Java home:

$ /usr/libexec/java_home

…then, the cacerts file is located under there, in jre/lib/security.

Also, as Evan T pointed out in the comments, the password is “changeit”. This is pretty much universal for all JVMs I’ve used (including Linux/Windows).

And one more thing. It’s a good idea to specify a -alias parameter when adding the certificate, otherwise it gets added under the alias “mykey”, then if you try to add another one, you get an error, since it’s trying to add another “mykey”.

Nerd bucket list

I’ve been doing pretty much straight Java programming for the last 4 years and it has not escaped my attention that Java seems to be falling out of favor in the programming community.  Anyway, I’m currently spending some time branching out and learning a few other languages/frameworks/etc.  I’ve also been going on a tour of the various nerd meetings in Phoenix, seeing what the user communities are up to and which are most vibrant.  I made a semi-prioritized list of things I want to learn, which is based on stuff I’ve read online, what’s cool locally, and personal preference, so here it is:

  1. ruby/rails
  2. iphone/objective c
  3. scala
  4. javascript (already familiar, but become a master)
  5. node.js
  6. haskell
  7. groovy/grails
  8. python