Automator fails. Is there a better solution? Recently I was trying to train an Automator script to run some mundane tasks - unfortunately it stops at the first step.

I clicked the "record" button on my old Mac OS 10.5 machine, opened Keychain and did a few more steps. It failed on the first step unfortunately - the cursor just points to the spot a little to the right of where Keychain shows on the bottom dock. (Yes, I tried turning off autohiding, and the jumpout effect)

On a newer Mac it was actually worse, when recording and playing back the steps it didn't give an alert saying it failed, it just kept pressing the mouse down, down, toward the icon, and never clicking it.

If Automator isn't the best tool for what it says it does, what is the best solution?

Since this will be programmatically called, one natural choice might be the Java Robot class - unfortunately it seems this does simple key press, key-up, mouse movement, but doesn't seem to have the smarts Automator has.

Sikuli seems like possibly a good solution, but I can't test right now as it apparently only works on OS 10.6+ (and earlier than 10.10). It also sounds a bit hacky, how it uses image processing to find what you're looking for.

I know there are OpenSSL commands that do the same as the Keychain, but for the purposes of this automation it has to be known by the system - which from what I can tell requires certs to be in the Keychain. I need a solution that can be scripted.
You can add certs to a keychain with the command line tool security

It's been a while since I've used it, but IIRC the command would be:

security add-trusted-cert -r trustRoot -k /path/to/keychain /path/to/cert

Read the man page:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/security.1.html