compat.ngtcp2
#includeRFC 9000 QUIC protocol implementation in C (native in-graph static build)
#include <ngtcp2/ngtcp2_crypto_ossl.h>
mcpp add compat.ngtcp2@1.26.0
Usage
From this repository's own test project — built and run by CI, not written for the website.
#include <ngtcp2/ngtcp2_crypto_ossl.h>
#include <openssl/ssl.h>
#include <memory>
// 同时建立客户端和服务端 TLS 会话,验证静态库的后端符号和 OpenSSL 传递依赖
int main() {
if (ngtcp2_crypto_ossl_init() != 0) return 1;
std::unique_ptr<SSL_CTX, decltype(&SSL_CTX_free)> factory(SSL_CTX_new(TLS_method()), SSL_CTX_free);
if (!factory) return 2;
for (bool server : {false, true}) {
std::unique_ptr<SSL, decltype(&SSL_free)> tls(SSL_new(factory.get()), SSL_free);
if (!tls) return 3;
ngtcp2_crypto_ossl_ctx* raw = nullptr;
if (ngtcp2_crypto_ossl_ctx_new(&raw, tls.get()) != 0) return 4;
std::unique_ptr<ngtcp2_crypto_ossl_ctx, decltype(&ngtcp2_crypto_ossl_ctx_del)> session(raw, ngtcp2_crypto_ossl_ctx_del);
if (ngtcp2_crypto_ossl_ctx_get_ssl(session.get()) != tls.get()) return 5;
auto status = server ? ngtcp2_crypto_ossl_configure_server_session(tls.get())
: ngtcp2_crypto_ossl_configure_client_session(tls.get());
if (status != 0) return 6;
}
ngtcp2_crypto_ossl_free();
// …
tests/examples/ngtcp2-openssl/tests/tls_backend.cpp · project tests/examples/ngtcp2-openssl
Build
- targets
ngtcp2 (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/lib/includes, */crypto/includes, */lib, */crypto, mcpp_generated/include, mcpp_generated
Features
| feature | declares |
|---|---|
| staticlib | defines |
| default | implies |
| openssl | deps, sources, implies |
Sources (1)
*/lib/*.c
Generated files
mcpp_generated/include/ngtcp2/version.hmcpp_generated/config.h
Versions
| Version | Platforms | Mirrors | sha256 |
|---|---|---|---|
1.26.0 latest |
LinuxWindowsmacOS | source | 85174d674e7f… |