iosOpenssl

https://github.com/x2on/OpenSSL-for-iPhone
cd /path/OpenSSL-for-iPhone-master $ ./build-libssl.sh
iOS编译OpenSSL静态库
iOS编译OpenSSL静态库
https://github.com/NMSSH/NMSSH

./build-libssl.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
$ ./build-libssl.sh
...
Build options
OpenSSL version: 1.1.1d
Targets: ios-sim-cross-x86_64 ios64-cross-arm64 ios64-cross-arm64e tvos-sim-cross-x86_64 tvos64-cross-arm64
iOS SDK: 13.2
tvOS SDK: 13.2
Number of make threads: 8
Configure options: no-deprecated
Build location: /Users/choe/github/ios/OpenSSL-for-iPhone

Downloading openssl-1.1.1d.tar.gz...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8638k 100 8638k 0 0 148k 0 0:00:58 0:00:58 --:--:-- 190k
Building openssl-1.1.1d for iPhoneSimulator 13.2 x86_64...
Logfile: /Users/choe/github/ios/OpenSSL-for-iPhone/bin/iPhoneSimulator13.2-x86_64.sdk/build-openssl-1.1.1d.log
Configure...
Make (using 8 thread(s))...
Building openssl-1.1.1d for iPhoneOS 13.2 arm64...
Logfile: /Users/choe/github/ios/OpenSSL-for-iPhone/bin/iPhoneOS13.2-arm64.sdk/build-openssl-1.1.1d.log
Configure...
Make (using 8 thread(s))...
Building openssl-1.1.1d for iPhoneOS 13.2 arm64e...
Logfile: /Users/choe/github/ios/OpenSSL-for-iPhone/bin/iPhoneOS13.2-arm64e.sdk/build-openssl-1.1.1d.log
Configure...
Make (using 8 thread(s))...
Building openssl-1.1.1d for AppleTVSimulator 13.2 x86_64...
Logfile: /Users/choe/github/ios/OpenSSL-for-iPhone/bin/AppleTVSimulator13.2-x86_64.sdk/build-openssl-1.1.1d.log
Configure...
Make (using 8 thread(s))...
Building openssl-1.1.1d for AppleTVOS 13.2 arm64...
Logfile: /Users/choe/github/ios/OpenSSL-for-iPhone/bin/AppleTVOS13.2-arm64.sdk/build-openssl-1.1.1d.log
Configure...
Make (using 8 thread(s))...
Build library for iOS...

=====>iOS SSL and Crypto lib files:
/Users/choe/github/ios/OpenSSL-for-iPhone/lib/libssl.a
/Users/choe/github/ios/OpenSSL-for-iPhone/lib/libcrypto.a
Build library for tvOS...

=====>tvOS SSL and Crypto lib files:
/Users/choe/github/ios/OpenSSL-for-iPhone/lib/libssl-tvOS.a
/Users/choe/github/ios/OpenSSL-for-iPhone/lib/libcrypto-tvOS.a

=====>Include directory:
/Users/choe/github/ios/OpenSSL-for-iPhone/include/
Done.



cp -rv lib /Users/choe/github/ios/toolBar/Strongbox/lib/OpenSSL/

ld: warning: directory not found for option '-L/Users/choe/github/ios/toolBar/Strongbox/lib/NMSSH/NMSSH-iOS/Libraries/lib'
ld: library not found for -lssh2
clang: error: linker command failed with exit code 1 (use -v to see invocation)


# read https://github.com/NMSSH/NMSSH/wiki/Build-and-use-in-your-iOS-project
# https://github.com/Frugghi/iSSH2
# https://www.libssh2.org/

~/github/ios/StrongboxLibraryByChoe/NMSSH on  master ⌚ 18:35:41
$ cp -rv ./NMSSH-iOS/Libraries/lib /Users/choe/github/ios/toolBar/Strongbox/lib/NMSSH/NMSSH-iOS/Libraries

# https://github.com/Yubico/yubikit-ios
~/github/ios/toolBar/StrongboxLibraryByChoe/yubikit-ios/YubiKit/releases/YubiKit on  master ⌚ 23:34:22
$ cp -rv YubiKit /Users/choe/github/ios/toolBar/Strongbox/lib/

Find the ${PROJECT_DIR} for an Xcode project

x2on.de

contact / imprint

Tutorial: iPhone App with compiled OpenSSL Library

Feb 1, 2010

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 0.9.8o and Xcode 3.2 with iPhoneOS 3.1.3. An updated version of this tutorial for OpenSSL 1.0 and Xcode 3.2.3 with iOS 4 is here: http://www.x2on.de/2010/07/13/tutorial-iphone-app-with-compiled-openssl-1-0-0a-library/

UPDATE 2010-07-13: New tutorial for OpenSSL 1.0.0a and iOS4 UPDATE 2010-06-30: I have updated OpenSSL to 1.0.0a with iOS 4.0 as base SDK UPDATE 2010-06-10: I have updated OpenSSL to 0.9.8o + iPad Version UPDATE 2010-03-31: I have updated OpenSSL to 0.9.8n UPDATE 2010-02-26: I have updated OpenSSL to 0.9.8m

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
  • Build OpenSSL for i368 iPhoneSimulator:
1
2
3
4
cd openssl-0.9.8o
mkdir openssl_arm
mkdir openssl_i386
./config --openssldir=/Users//openssl-0.9.8o/openssl_i386
  • Edit Makefile:
  • Change CC = cc to:
1
2
make
CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0
  • Add as first item to CFLAG:
1
2
3
4
5
6
make   
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk
* Change in crypto/ui/ui_openssl.c


static volatile sig_atomic_t intr_signal;

to

1
static volatile int intr_signal;

for preventing building error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
* Build it:


make
make install





* 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:

    • mv openssl_i386 openssl_i386_lib make clean

    • Edit Makefile:

      • Search and replace openssl_i386 with openssl_arm
      • Change -arch i386 in CFLAG to: -arch armv6
      • Change

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

to

1
2
3
4
5
6
7
8
9
10
CC=  /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0





* Change


-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk

to

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-isysroot  /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk








* Build it:


make
make install





* 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 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

    $(inherited) “$(SRCROOT)”

  • 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.8o 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: