This is a tutorial for using self-compiled builds of the OpenSSL-library on the iPhone. You can build apps with XCode and the official SDK from Apple with this. I also made a small example-app for using the libraries with XCode and the iPhone/iPhone-Simulator. You can also download the precompiled OpenSSL-library (1.0.0a).
This tutorial works with OpenSSL 1.0.0a and Xcode 3.2.3 with iOS 4.
Update: Script for automatic building OpenSSL (currently 1.0.0d) for iOS: http://www.x2on.de/2010/12/16/tutorial-script-for-building-openssl-for-ios-iphoneipad/
You can find the tutorial for OpenSSL 0.9.8 at http://www.x2on.de/2010/02/01/tutorial-iphone-app-with-compiled-openssl-library/
You can get the Source of the example app with compiled OpenSSL at http://github.com/x2on/OpenSSL-for-iPhone
Create OpenSSL Libary:
Download OpenSSL Sourcecode
Change in crypto/ui/ui_openssl.c
|
to
|
for preventing building error
Build OpenSSL for i368 iPhoneSimulator:
|
Edit Makefile:
Change CC = cc
to:
|
Add as first item to CFLAG
:
|
Build it:
|
Your libcrypto.a and libssl.a are in the folder openssl_i368/lib
Build OpenSSL for armv6 iOS:
|
Edit Makefile:
Change CC = cc
to:
|
Add as first item to CFLAG
:
|
Build it:
|
Your libcrypto.a and libssl.a are in the folder openssl_armv6/lib
Build OpenSSL for armv7 iOS:
|
Edit Makefile:
Change CC = cc
to:
|
Add as first item to CFLAG
:
|
Build it:
|
Your libcrypto.a and libssl.a are in the folder openssl_armv7/lib
Create universal libs:
|
Edit your iPhone-XCode project:
Copy the “include” folder from OpenSSL into your project-folder
Copy the libcrypto.a and libssl.a files into your project-folder
Drag the libcrypto.a and libssl.a files into your XCode Framework Folder-Tree
Open the Build-Info from your “Target” (Righclick on Target – Get Info)
Change _Library Search Paths_
to
|
Change _User Header Search Paths_
to _include_
Activate _Always Search User Paths_
Enjoy OpenSSL on the iPhone!
I have made an iOS 3.2/4.0 XCode Project with OpenSSL 1.0.0a libaries. The examples uses the MD5-algorithm to calculate an md5 hash from an UITextfield.
Download: http://github.com/x2on/OpenSSL-for-iPhone
Disclaimer: Use this at your own risk.
Links: