Swiftpack.co - muzipiao/GMOpenSSL as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
muzipiao/GMOpenSSL
openssl 1.1.1i 的 framework 版本,发布至 cocoapods,方便集成。
.package(url: "https://github.com/muzipiao/GMOpenSSL.git", from: "2.2.6")

GMOpenSSL

Version License Platform

cocoapods 不支持直接集成 OpenSSL,将 OpenSSL 源码编译为 framework,并发布至 cocoapods,名称为 GMOpenSSL,方便通过 cocoapods 集成。

版本映射

GMOpenSSL 版本 OpenSSL 版本 支持架构 Bitcode 兼容iOS版本
2.2.6 1.1.1l x86_64 arm64 包含 >= iOS 9.0
2.2.4 1.1.1l x86_64 arm64 arm64e armv7 armv7s 包含 >= iOS 8.0

CocoaPods

CocoaPods 是最简单方便的集成方法,编辑 Podfile 文件,添加

pod 'GMOpenSSL'

然后执行 pod install 即可,默认最新版本。

自定义编译 OpenSSL

如果编译的静态库不能满足需求,可以自行运行脚本编译。工程目录下有一个名称为 OpenSSL_BUILD 的文件夹,依次执行 cd 切换到当前目录下,然后执行./build-libssl.sh,待执行完毕再执行./create-openssl-framework.sh,即可看到编译完成的 openssl.framwork。

打包完成的静态库并未暴露国密的头文件,解压缩下载的 openssl 压缩包,如 openssl-1.1.1l.tar.gz,将 include/crypto/ 路径下的 sm2.h、sm3.h,sm4.h 都拖到 openssl.framework/Headers 文件夹下即可。

opensslconf.h 头文件条件编译末尾做如下修改

# error Unable to determine target or target not included in OpenSSL build

修改为:

# include <openssl/opensslconf_ios_arm64.h>

GitHub

link
Stars: 28
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics