Building OpenSSL on your Mac (MacOS X)

This posting is intended for my team of iPhone Developers only:

Steps to Build OpenSSL 1.0.0c under your MacOS X:

01. Visit http://www.openssl.org/source/,
and download: openssl-1.0.0c.tar.gz

02. Open a Terminal Console (where you can enter Unix command)

03. Create a new folder as follow:
mkdir opensources
cd opensources

04. Copy openssl-1.0.0c.tar.gz under /opensources as follow:
cp /Users/{your login name}/Downloads/openssl-1.0.0c.tar.gz .

05. Unzip openssl-1.0.0c.tar.gz as follow:
tar -zxvf openssl-1.0.0c.tar.gz

06. cd into openssl-1.0.0c as follow:
cd openssl-1.0.0c

07. Find out your CPU architecture: 32 bits or 64 bits
I am not sure how, but you have to find it out

08. Back to Terminal Console, and under
/opensources/openssl-1.0.0c, and do this:
./Configure

You should see the followings:
MacBook-Pro:openssl-1.0.0c oscar$ ./Configure
Usage: Configure [no- ...] [enable- ...] [experimental- ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]

pick os/compiler from:
… darwin-i386-cc darwin-ppc-cc darwin64-ppc-cc
darwin64-x86_64-cc dgux-R3-gcc dgux-R4-gcc ….

For my MacBook MacOS X, I have Intel Core 2 Duo 64 bits which is:
“darwin64-x86_64-cc” from the list. If you have a new (after 2006) MacBook Pro with Intel processor, most likely you will use “darwin64-x86_64-cc”

09. Configure OpenSSL as follow:
./Configure darwin64-x86_64-cc  –prefix=/usr no-threads shared
(Note: there are two “minus signs” in front of “prefix” like –)
This will take a few minutes.

10. make
(if you see an error such as Permission Denied, you should do:
sudo make, and it will ask for the
machine’s administrative password)
This will build OpenSSL, and it will take a few minutes
up to 30 minutes.

11. make install (or, sudo make install)
This will take a few minutes

12. Close the Terminal Console

13. Open a new Terminal Console, and type the followings:
openssl

14. Then, you should see a OpenSSL> command prompt, and then,
enter: version
Check to see if the version is 1.0.0c.

15. Enter quit to exit the OpenSSL> command prompt.

16. Then, check if the libraries are there by doing the following:
ls -l /usr/lib/*ssl*

And, you should see:
-r-xr-xr-x  1 root  wheel  401168 Jan 15 11:36 /usr/lib/libssl.1.0.0.dylib
-rw-r–r–  1 root  wheel  534408 Jan 15 11:36 /usr/lib/libssl.a
lrwxr-xr-x  1 root  wheel      18 Jan 15 11:36 /usr/lib/libssl.dylib -> libssl.1.0.0.dylib

17. And, you see that *.dylib ?
Remember, we did a similar step to load sqlite3.dylib before ?
Please do the same for your iPhone app.
Just try it, and let me know when you are done.

18. If Step 17 is successful, I will continue to show you how to include
the necessary OpenSSL C Header file, and write a simple example
for AES data encryption and decryption.

Email me at my hotmail email account if you have any issues…

Oscar
Founder of FoodPicky.com

Leave a Reply