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 (0.9.8m-beta1).
You can get the Source of the example app with compiled OpenSSL athttp://github.com/x2on/OpenSSL-for-iPhone
Create OpenSSL Libary:
- Download OpenSSL Sourcecode
- Build OpenSSL for i368 iPhoneSimulator:
- Edit Makefile:
- Change CC = cc to:
- Add as first item to CFLAG:
- Change in crypto/ui/ui_openssl.c
to
for preventing building error
- Build it:
- Your libcrypto.a and libssl.a are in the folder openssl_i368/lib
- Rename the two files to libcrypto_i386.a and libssl_i386.a
- Build OpenSSL for arm iPhoneOS:
- Edit Makefile:
- Search and replace openssl_i386 with openssl_arm
- Change -arch i386 in CFLAG to:
-arch armv6 - Change
to
- Change
to
- Build it:
- Your libcrypto.a and libssl.a are in the folder openssl_arm/lib
- Rename the two files to libcrypto_arm.a and libssl_arm.a
- Edit Makefile:
Edit your iPhone-XCode project:
- Copy the “include” folder from OpenSSL into your project-folder
- Copy the libcrypto_*.a and libss_*.a files into your project-folder
- Drag the libcrypto_*.a and libss_*.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 iPhone OS 3.1.2 XCode Project with OpenSSL 0.9.8m (Beta1) Libaries. The examples uses the MD5-algorithm to calculate an md5 hash from an UITextfield.
Download: OpenSSL-1 iPhone Example Project (2,9MB)
Download: OpenSSL-iPhone-0.9.8m-beta1-i386-arm (2,0MB)
Disclaimer: Use this at your own risk.
Links:
- http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/
- http://www.openssl.org/
- http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html
Tags: Apple, iPhone, Objective-C, OpenSSL, XCode
댓글