Working Around Apple’s Deprecation of OpenSSL

Apple has started deprecating OpenSSL on Mac OS X 10.7 SDK and later. I guess they’d prefer you use SecTransform or something. Unfortunately SecTransform isn’t on iOS yet and even it were, some of us have codebases that aren’t Apple-platform exclusive. Feels kind of like a dick move to me.

Anyway, I continued to use OpenSSL in my code — I just stuck a big fat

#pragma clang diagnostic ignored "-Wdeprecated-declarations"

on the top of my OpenSSL-using source files.

Unfortunately that turns off deprecation warnings for the entire file. I tried downloading OpenSSL (/usr/include/openssl/opensslv.h’s OPENSSL_VERSION_TEXT indicates you want v0.9.8r) and using their header files directly but was stumped:

rentzsch / @rentzsch:

lazytwitter: how do I get Xcode to prefer my local openssl header dir to the SDK’s (that’s littered with with deprecation attributes)?

rentzsch / @rentzsch:

(setting ALWAYS_SEARCH_USER_PATHS, HEADER_SEARCH_PATHS & USER_HEADER_SEARCH_PATHS doesn’t seem to be enough or I’m doing it wrong)

Fortunately Christopher Lloyd answered my query:

Christopher Lloyd / @cjwl:

@rentzsch -isystem <myincludedir> added using other c flags should do it

I just tried it and it works. Thanks again, Christopher!

Update: I take back my “feels kind of like a dick move” statement. There are good reasons for Apple to deprecate OpenSSL, I just wish they wrote a Technote about it. So I wrote one for them as penance. Apologies, Apple peeps.

openssl Oct 15 2012