Skip to content

feat: add compat.openssl 3.5.1 + asio SSL/TLS support - #124

Merged
Sunrisepeak merged 11 commits into
mcpplibs:mainfrom
wellwei:feat/add-openssl-asio-tls
Jul 26, 2026
Merged

feat: add compat.openssl 3.5.1 + asio SSL/TLS support#124
Sunrisepeak merged 11 commits into
mcpplibs:mainfrom
wellwei:feat/add-openssl-asio-tls

Conversation

@wellwei

@wellwei wellwei commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

变更内容

新增 compat.openssl@3.5.1

  • Form B 描述符,install()-driven 构建(参考 compat.openblas 模式)
  • 静态库产物:libcrypto.a + libssl.a + include/openssl/*.h
  • 平台:Linux/macOS 从源码编译,Windows 暂缓

chriskohlhoff.asio 新增 ssl feature

  • opt-in,非默认 feature
  • 激活方式:features = ["ssl"]
  • 依赖 compat.openssl@3.5.1
  • .cppm 内 MCPP_FEATURE_SSL 守卫,导出 asio::ssl 命名空间
  • 新增 asio_ssl.cpp 源码编译

新增 SSL 测试 tests/examples/asio-module/tests/ssl.cpp

  • TLS echo 端到端测试(PEM 内嵌)
  • #ifdef MCPP_FEATURE_SSL no-op 回退(feature 未激活时)

已验证

  • compat.openssl 独立构建:OpenSSL 3.5.1 源码编译,libcrypto.a + libssl.a + headers 产出正确
  • asio 现有测试:6/6 pass(core, coroutine, experimental, network, surface, ssl no-op)
  • asio + ssl feature 端到端:TLS echo 测试通过(独立项目,合并索引验证)
  • CI lint ✅
  • CI workspace (macOS/Linux/Windows) ✅

边界限制

  1. Windows 暂不支持:需要预编译 MSVC 静态库上传 xlings-res,不在本次范围
  2. CN 镜像待上传:OpenSSL 3.5.1 tarball (50.7MB) 需上传 gitcode.com/mcpp-res/openssl
  3. ssl feature 端到端无法在 workspace 内测试:xlings#374 限制,不能同时从本地路径解析 chriskohlhoffcompat 两个 namespace。待 compat.openssl 发布到全局索引后可正常工作
  4. verify_ 常量无法导出*:verify_none/verify_peer/verify_fail_if_no_peer_cert 为内部链接 const int,C++20 module 语法限制无法 export。消费者需使用裸 int 值或通过 context_base 枚举
  5. rfc2818_verification 不存在于 asio 1.38.1

mbedTLS 评估结论

mbedTLS 无法替代 OpenSSL 作为 asio 的 TLS 依赖。asio::ssl 硬编码 ~95 个 OpenSSL C API(SSL_CTX/SSL/BIO/X509/EVP/ERR/PEM 等),mbedTLS API 完全不同且无 OpenSSL 兼容层。

wellwei added 11 commits July 26, 2026 20:26
Without the ssl feature active, ssl.cpp compiles to a trivially-passing
no-op (int main() { return 0; }). This keeps the workspace green while
compat.openssl is unpublished (xlings#374 prevents two local-path index
repos for cross-namespace resolution).
…line constexpr

rfc2818_verification does not exist in standalone asio 1.38.1.
verify_none/verify_peer/verify_fail_if_no_peer_cert are const int with
internal linkage — cannot be exported via 'using'.  Replace with inline
constexpr declarations backed by the OpenSSL SSL_VERIFY_* macros.
verify_* are const int with internal linkage — cannot be exported via
using or inline constexpr (re-declaration conflicts with global module
fragment).  Keep only types (context, context_base, stream, verify_mode)
and host_name_verification function.
@Sunrisepeak
Sunrisepeak merged commit a5e125a into mcpplibs:main Jul 26, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants