Easy inclusion of OpenSSL into iOS projects

Oddly, iOS doesn’t provide any OpenSSL implementation at all — If you want to do anything with crypto (like checking signatures, checksumming, etc.), you have to build in the library yourself.

I came across a great XCode project wrapper for OpenSSL yesterday, by Stephen Lombardo. This is an XCode project file that contains a target to build OpenSSL from source, and works with both Mac and iOS projects. I made some modifications to it, in order to make it work by just dropping in the OpenSSL source tarball, without having to dirty up your source tree with the extracted OpenSSL distribution.

Here’s how to use it:

  1. Download the OpenSSL source.
  2. Put the downloaded OpenSSL source tar.gz into the same folder as openssl.xcodeproj (I put it in Library/openssl within my project tree).
  3. Drag the openssl.xcodeproj file into your main project tree in XCode.
  4. Right-click on your project target, and add openssl.xcodeproj under “Direct Dependencies” on the General tab.
  5. On the Build tab for your project’s target, find the “Header Search Paths” option, and add the path:


    (Assuming you’ve put openssl.xcodeproj at the path Library/openssl — adjust as necessary).

  6. Expand your target’s “Link Binary With Libraries” build stage, and drag libcrypto.a from the openssl.xcodeproj group.

Then, you can just import and use as normal (#import <openssl/dsa.h>, etc).

Download it here

, , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Posted November 26, 2011 at 12:49 am | Permalink

    Ahh, that’s maybe where I was hosing it up. I had my folders completely different than that.

  2. Posted February 7, 2012 at 9:13 am | Permalink


    could you please update the post for Xcode 4? The build folder is in a different location there … or there is something else wrong. I followed the guide to the letter, but it does not build.

    regards Oliver

  3. Adrian Willis
    Posted February 9, 2012 at 4:06 pm | Permalink

    I am struggling to get the certificate expiry date using openssl, do you happen to have any source code that would show me how? Much appreciated in advance


  4. Posted April 6, 2013 at 8:03 am | Permalink

    I am not getting step 2 & 3. According to me –

    Step 2 – We have to create one project named as “openssl.xcodeproj ” and we have to put openssl library in same folder like this ” Library/openssl “

    Step 3 – Crete New project and add project created in step 2.

    Is am doing anything wrong. Please help me out.

    Thank you Nitesh

  5. Shivanand
    Posted July 11, 2013 at 8:57 pm | Permalink

    I think there is some issue with openssl and iphone simulator. RAND_poll crashes on simulator. This can be reproduced by simply trying to create a random number using openssl.