apotocki/openssl-iosx

GitHub: apotocki/openssl-iosx

为 Apple 全平台自动构建 OpenSSL 库并打包为 XCFrameworks 的构建分发工具。

Stars: 26 | Forks: 13

# openssl-iosx ## 概述 `openssl-iosx` 是一个构建和分发项目,旨在为 Apple 平台生成**打包为 XCFrameworks 的预编译 OpenSSL 静态库**。 本仓库**不包含预编译的 OpenSSL 二进制文件**。 预编译产物通过 **GitHub Releases** 单独发布。 本仓库**不包含 OpenSSL 源代码**,也**不提供 OpenSSL API 文档或使用示例**。 本项目的范围特意仅限于构建和分发二进制文件。 ## 支持的平台 OpenSSL 库构建适用于: * iOS / iOS Simulator * watchOS / watchOS Simulator * tvOS / tvOS Simulator * visionOS / visionOS Simulator * macOS * Mac Catalyst 在适用的地方,同时支持 Intel (`x86_64`) 和 Apple Silicon (`arm64`) 架构。 ## 支持的 OpenSSL 版本 支持的 OpenSSL 4.0.x 上游版本:[4.0.0](https://github.com/apotocki/openssl-iosx/tree/4.0.0) 支持的 OpenSSL 3.6.x 上游版本:[3.6.2](https://github.com/apotocki/openssl-iosx/tree/3.6.2), [3.6.1](https://github.com/apotocki/openssl-iosx/tree/3.6.1), [3.6.0](https://github.com/apotocki/openssl-iosx/tree/3.6.0) 支持的 OpenSSL 3.5.x 上游版本:[3.5.6](https://github.com/apotocki/openssl-iosx/tree/3.5.6), [3.5.5](https://github.com/apotocki/openssl-iosx/tree/3.5.5), [3.5.4](https://github.com/apotocki/openssl-iosx/tree/3.5.4), [3.5.3](https://github.com/apotocki/openssl-iosx/tree/3.5.3), [3.5.2](https://github.com/apotocki/openssl-iosx/tree/3.5.2), [3.5.1](https://github.com/apotocki/openssl-iosx/tree/3.5.1), [3.5.0](https://github.com/apotocki/openssl-iosx/tree/3.5.0) 支持的 OpenSSL 3.4.x 上游版本:[3.4.6](https://github.com/apotocki/openssl-iosx/tree/3.4.6), [3.4.5](https://github.com/apotocki/openssl-iosx/tree/3.4.5), [3.4.4](https://github.com/apotocki/openssl-iosx/tree/3.4.4), [3.4.3](https://github.com/apotocki/openssl-iosx/tree/3.4.3), [3.4.2](https://github.com/apotocki/openssl-iosx/tree/3.4.2), [3.4.1](https://github.com/apotocki/openssl-iosx/tree/3.4.1), [3.4.0](https://github.com/apotocki/openssl-iosx/tree/3.4.0) 支持的 OpenSSL 3.3.x 上游版本:[3.3.7](https://github.com/apotocki/openssl-iosx/tree/3.3.7), [3.3.6](https://github.com/apotocki/openssl-iosx/tree/3.3.6), [3.3.5](https://github.com/apotocki/openssl-iosx/tree/3.3.5), [3.3.4](https://github.com/apotocki/openssl-iosx/tree/3.3.4), [3.3.3](https://github.com/apotocki/openssl-iosx/tree/3.3.3), [3.3.2](https://github.com/apotocki/openssl-iosx/tree/3.3.2), [3.3.1](https://github.com/apotocki/openssl-iosx/tree/3.3.1), [3.3.0](https://github.com/apotocki/openssl-iosx/tree/3.3.0) 支持的 OpenSSL 3.2.x 上游版本:[3.2.6](https://github.com/apotocki/openssl-iosx/tree/3.2.6), [3.2.5](https://github.com/apotocki/openssl-iosx/tree/3.2.5), [3.2.4](https://github.com/apotocki/openssl-iosx/tree/3.2.4), [3.2.3](https://github.com/apotocki/openssl-iosx/tree/3.2.3), [3.2.2](https://github.com/apotocki/openssl-iosx/tree/3.2.2), [3.2.1](https://github.com/apotocki/openssl-iosx/tree/3.2.1), [3.2.0](https://github.com/apotocki/openssl-iosx/tree/3.2.0) 支持的 OpenSSL 3.1.x 上游版本:[3.1.8](https://github.com/apotocki/openssl-iosx/tree/3.1.8), [3.1.7](https://github.com/apotocki/openssl-iosx/tree/3.1.7), [3.1.6](https://github.com/apotocki/openssl-iosx/tree/3.1.6), [3.1.5](https://github.com/apotocki/openssl-iosx/tree/3.1.5), [3.1.4](https://github.com/apotocki/openssl-iosx/tree/3.1.4), [3.1.3](https://github.com/apotocki/openssl-iosx/tree/3.1.3), [3.1.2](https://github.com/apotocki/openssl-iosx/tree/3.1.2), [3.1.1](https://github.com/apotocki/openssl-iosx/tree/3.1.1), [3.1.0](https://github.com/apotocki/openssl-iosx/tree/3.1.0) 支持的 OpenSSL 3.0.x 上游版本:[3.0.21](https://github.com/apotocki/openssl-iosx/tree/3.0.21), [3.0.20](https://github.com/apotocki/openssl-iosx/tree/3.0.20), [3.0.19](https://github.com/apotocki/openssl-iosx/tree/3.0.19), [3.0.18](https://github.com/apotocki/openssl-iosx/tree/3.0.18), [3.0.17](https://github.com/apotocki/openssl-iosx/tree/3.0.17), [3.0.16](https://github.com/apotocki/openssl-iosx/tree/3.0.16), [3.0.15](https://github.com/apotocki/openssl-iosx/tree/3.0.15), [3.0.14](https://github.com/apotocki/openssl-iosx/tree/3.0.14), [3.0.13](https://github.com/apotocki/openssl-iosx/tree/3.0.13), [3.0.12](https://github.com/apotocki/openssl-iosx/tree/3.0.12), [3.0.11](https://github.com/apotocki/openssl-iosx/tree/3.0.11), [3.0.10](https://github.com/apotocki/openssl-iosx/tree/3.0.10), [3.0.9](https://github.com/apotocki/openssl-iosx/tree/3.0.9), [3.0.8](https://github.com/apotocki/openssl-iosx/tree/3.0.8), [3.0.7](https://github.com/apotocki/openssl-iosx/tree/3.0.7) 支持的 OpenSSL 1.1.1 字母版本:[1.1.1w](https://github.com/apotocki/openssl-iosx/tree/1.1.1w), [1.1.1v](https://github.com/apotocki/openssl-iosx/tree/1.1.1v), [1.1.1u](https://github.com/apotocki/openssl-iosx/tree/1.1.1u), [1.1.1t](https://github.com/apotocki/openssl-iosx/tree/1.1.1t), [1.1.1s](https://github.com/apotocki/openssl-iosx/tree/1.1.1s), [1.1.1q](https://github.com/apotocki/openssl-iosx/tree/1.1.1q), [1.1.1p](https://github.com/apotocki/openssl-iosx/tree/1.1.1p), [1.1.1o](https://github.com/apotocki/openssl-iosx/tree/1.1.1o), [1.1.1n](https://github.com/apotocki/openssl-iosx/tree/1.1.1n), [1.1.1m](https://github.com/apotocki/openssl-iosx/tree/1.1.1m), [1.1.1l](https://github.com/apotocki/openssl-iosx/tree/1.1.1l), [1.1.1k](https://github.com/apotocki/openssl-iosx/tree/1.1.1k), [1.1.1j](https://github.com/apotocki/openssl-iosx/tree/1.1.1j), [1.1.1i](https://github.com/apotocki/openssl-iosx/tree/1.1.1i) 使用适当的 **Git tag 或分支** 来选择所需的 OpenSSL 版本。 ### 版本控制策略 分支对应于官方的 OpenSSL 版本。 Tags 和 GitHub Releases 使用格式 `.`(例如 `3.0.19.0`),其中 `package_patch` 是本仓库针对该上游 OpenSSL 版本的打包/构建修订号。 在此打包修订号之外,没有独立的语义化版本控制。 这种设计是刻意为之,旨在提供: * 透明度 * 可预测的依赖管理 * 更容易的安全审计和合规性 ## OpenSSL 源码 实际的 OpenSSL 源代码是从官方上游仓库获取的: [https://github.com/openssl/openssl](https://github.com/openssl/openssl) 使用相应的上游 tag(例如 `OpenSSL_1_1_1w` 或 `openssl-3.2.1`)。 ## 前置条件 1. **安装 Xcode** 需要 Xcode,因为创建 XCFrameworks 需要用到 `xcodebuild`。 2. **验证 Xcode 开发者目录** `xcode-select -p` 命令必须指向 Xcode 开发者目录(例如 `/Applications/Xcode.app/Contents/Developer`)。 如果它指向 Command Line Tools 目录,请使用以下任一命令重置: sudo xcode-select --reset 或 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 3. **安装所需的 SDK** 要构建适用于 tvOS、watchOS、visionOS 及其模拟器的版本,请确保在以下位置安装了相应的 SDK: /Applications/Xcode.app/Contents/Developer/Platforms ## 手动构建 ``` # 克隆 repository git clone https://github.com/apotocki/openssl-iosx # 构建 libraries cd openssl-iosx scripts/build.sh # 构建 artifacts 将位于 `frameworks` 目录中 ``` ## 选择平台和架构 不带参数运行 `build.sh` 会为 iOS、macOS 和 Catalyst 构建 XCFrameworks。如果安装了相应的 SDK,它还会为 watchOS、tvOS、visionOS 以及所有可用的模拟器进行构建。 模拟器架构(arm64 或 x86_64)会根据宿主系统自动选择。 要构建特定的平台和架构集合,请使用 `-p` 选项。例如: ``` scripts/build.sh -p=ios,iossim-x86_64 # 仅为 iOS devices 和 iOS Simulator (x86_64) 构建 XCFrameworks ``` `-p` 选项支持的值: ``` macosx,macosx-arm64,macosx-x86_64,macosx-both, ios,iossim,iossim-arm64,iossim-x86_64,iossim-both, catalyst,catalyst-arm64,catalyst-x86_64,catalyst-both, xros,xrossim,xrossim-arm64,xrossim-x86_64,xrossim-both, tvos,tvossim,tvossim-arm64,tvossim-x86_64,tvossim-both, watchos,watchossim,watchossim-arm64,watchossim-x86_64,watchossim-both ``` `-both` 后缀会同时为 `arm64` 和 `x86_64` 架构构建 XCFrameworks。不带架构后缀的平台名称(例如 `macosx`、`iossim`)仅针对当前宿主机的架构进行构建。 ## 重新构建选项 要强制执行全新的构建而不复用之前构建的产物,请使用 `--rebuild` 选项: ``` scripts/build.sh -p=ios,iossim-x86_64 --rebuild ``` ## 使用 CocoaPods 构建 本项目提供了一个 podspec,用于通过 CocoaPods 集成预编译的 OpenSSL 二进制文件。 将以下内容添加到您的 `Podfile` 中: ``` use_frameworks! pod 'openssl-iosx', '~> 4.0.0' # 或固定到特定的 tag # tag 格式为 .,例如:4.0.0.0 # pod 'openssl-iosx', :git => 'https://github.com/apotocki/openssl-iosx', :tag => '4.0.0.0' ``` 然后安装依赖项: ``` pod install --verbose ``` ## CI 和 Releases 所有二进制文件均使用 **GitHub Actions** 自动构建,并通过 **GitHub Releases** 发布。 本仓库维护了多个长期分支,对应不同的 OpenSSL 发布线。每个分支都有各自的构建工作流和发布历史。 因此,特意不显示全局构建状态徽章。 某个 tag 存在对应的 GitHub Release 即意味着该 OpenSSL 版本的 CI 构建成功。 ### 安全提示 为方便起见并展示构建脚本的预期输出,我们在 GitHub Releases 中提供了预编译的二进制文件。 对于安全敏感或生产环境的使用,**强烈建议**您使用提供的脚本在本地从源代码构建 OpenSSL,并自行验证生成的二进制文件。 ## 支持 仅通过 **GitHub Issues** 提供支持。 本项目重点关注构建的正确性和平台支持。有关 OpenSSL API 或使用的问题,请直接查阅 OpenSSL 官方文档。 ## 许可证 本仓库包含 OpenSSL 的构建脚本。 通过 GitHub Releases 发布的预编译产物仅为方便起见而提供,并受相应版本的上游 OpenSSL 许可证条款约束(例如,OpenSSL 3.x 采用 Apache License 2.0 授权)。 在使用或重新分发 OpenSSL 源代码或二进制文件时,请确保遵守特定版本的上游 OpenSSL 许可要求。
标签:Apple平台, Cutter, iOS, OpenSSL, XCFramework, 安全测试工具, 跨平台编译, 静态库