Wednesday, May 19, 2010

Missing Node crypto Functions on OS X?

While integrating the cookie-node library into the application framework I've built on top of Node, I ran into an unexpected error: the createHmac function was missing from Node's built-in crypto module. After reading some posts on Node's Google group, it seemed that it didn't like my openssl build; perhaps it's some issue with the version of openssl that ships with OS X 10.6.

To fix it, I did the following:

cd /usr/local/src
curl -O
tar -xzvf openssl-1.0.0.tar.gz
cd openssl-1.0.0.tar.gz
./configure --prefix=/usr/local
sudo make install
cd your/path/to/node/src
./configure --prefix=/usr/local
sudo make install
make test

(This assumes you're using /usr/local for sources you build, as some recommend.)

Interestingly, and frustratingly, ./configure for Node still reported that openssl was missing. But make test reported no failures, and the createHmac (and other missing functions) were now in the crypto module's exports. Yay!

I post this not only so I have it for reference next time (as I re-image my MBP often), but in case someone else encounters this problem.

Drew (

No comments:

Post a Comment