iPhone App with compiled OpenSSL 1.0.0a Library

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.

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

static volatile sig_atomic_t intr_signal;

to

static volatile int intr_signal;

for preventing building error

Build OpenSSL for i368 iPhoneSimulator:
mkdir ssllibs
cd openssl-1.0.0a
mkdir openssl_armv6 openssl_armv7 openssl_i386
./configure BSD-generic32 --openssldir=/Users/<username>/openssl-1.0.0a/openssl_i386
Edit Makefile:

Change CC = cc to:

CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386

Add as first item to CFLAG:

-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
Build it:
make
make install

Your libcrypto.a and libssl.a are in the folder openssl_i368/lib

Build OpenSSL for armv6 iOS:
mv openssl_i386 ../ssllibs
make clean
./configure BSD-generic32 --openssldir=/Users/<username>/openssl-1.0.0a/openssl_armv6
Edit Makefile:

Change CC = cc to:

CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6

Add as first item to CFLAG:

-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
Build it:
make
make install

Your libcrypto.a and libssl.a are in the folder openssl_armv6/lib

Build OpenSSL for armv7 iOS:
mv openssl_armv6 ../ssllibs
make clean
./configure BSD-generic32 --openssldir=/Users/<username>/openssl-1.0.0a/openssl_armv7
Edit Makefile:

Change CC = cc to:

CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7

Add as first item to CFLAG:

-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
Build it:
make
make install

Your libcrypto.a and libssl.a are in the folder openssl_armv7/lib

Create universal libs:

cp -r openssl_armv7/include ../ssllibs/
lipo -create ../ssllibs/openssl_i386/lib/libcrypto.a ../ssllibs/openssl_armv6/lib/libcrypto.a openssl_armv7/lib/libcrypto.a -output ../ssllibs/libcrypto.a
lipo -create ../ssllibs/openssl_i386/lib/libssl.a ../ssllibs/openssl_armv6/lib/libssl.a openssl_armv7/lib/libssl.a -output ../ssllibs/libssl.a
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

$(inherited) "$(SRCROOT)"

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:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值