从OS X 10.11开始，苹果SDK中不再提供OpenSSL标准库，官方文档中说明如下：
Although OpenSSL is commonly used in the open source community, OpenSSL does not provide a stable API from version to version. For this reason, although OS X provides OpenSSL libraries, the OpenSSL libraries in OS X are deprecated, and OpenSSL has never been provided as part of iOS. Use of the OS X OpenSSL libraries by apps is strongly discouraged.
If your app depends on OpenSSL, you should compile OpenSSL yourself and statically link a known version of OpenSSL into your app. This use of OpenSSL is possible on both OS X and iOS. However, unless you are trying to maintain source compatibility with an existing open source project, you should generally use a different API.
Common Crypto and Security Transforms are the recommended alternatives for general encryption. CFNetwork and Secure Transport are the recommended alternatives for secure communications.
A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in
This formula is keg-only, which means it was not symlinked into
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have this software first in your PATH run:
echo ‘export PATH=”/usr/local/opt/openssl/bin:$PATH”‘ >> ~/.zshrc
For compilers to find this software you may need to set:
For pkg-config to find this software you may need to set:
在对应位置找到OpenSSL静态库1$ open /usr/local/opt/openssl/lib
Library Search Paths中添加
Header Search Paths中添加
Always Search User Path设置为Yes
build settings -> preprocessor中添加一个
Set a preprocessor flag in XCode “WITH_TLS” by clicking the project in XCode then click the target then click build settingsSearch for preprocessor macros and add “WITH_TLS” to debug and release
build settings -> enable bitcode设置为NO即可