Skip to content

TLS Extensions: add signed_certificate_timestamp (RFC 6962) - #12257

Open
SparkiDev wants to merge 1 commit into
wolfSSL:masterfrom
SparkiDev:tls-ext-sct
Open

SparkiDev wants to merge 1 commit into
wolfSSL:masterfrom
SparkiDev:tls-ext-sct

Conversation

@SparkiDev

Copy link
Copy Markdown
Contributor

Description

Add the signed_certificate_timestamp extension for TLS 1.2 and TLS 1.3, enabled with --enable-sct (CMake WOLFSSL_SCT, macro HAVE_SIGNED_CERT_TIMESTAMP) and by --enable-all and --enable-tlsx. wolfSSL carries the SignedCertificateTimestampList between peers; validating the timestamps is left to the application.

  • wolfSSL_CTX_set_signed_cert_timestamp_list() and wolfSSL_set_signed_cert_timestamp_list() (BoringSSL names via wolfssl/openssl/ssl.h) set the list a server presents. The list is structurally checked and bounded by WOLFSSL_MAX_SCT_LIST_SZ. The context list is guarded by a mutex since it can be replaced while handshakes run.
  • wolfSSL_get0_signed_cert_timestamp_list() returns the peer's list and wolfSSL_signed_cert_timestamp_requested() reports whether the peer asked.
  • A client asks with an empty extension. The server answers in the ServerHello at TLS 1.2 (not on resumption) and on the end entity CertificateEntry at TLS 1.3. In a CertificateRequest it is accepted and ignored.
  • A context switch from an SNI callback moves the list with the certificate, and a list set from a callback after the ClientHello is still answered.
  • An application custom extension cannot be registered for type 18 when the extension is built in.

Crypto-only builds turn the option off, in configure and CMake alike.

Per-certificate extensions in the TLS 1.3 Certificate message are now built under WOLFSSL_CERT_ENTRY_EXTS (status_request or SCT, server side), with WriteCSRToBuffer() becoming WriteCertEntryExts(). Every site that builds, indexes or frees those buffers uses the same guard, so the send loop no longer reuses the leaf's entry for every certificate in the chain.

TLSX_GetResponseSize() now refuses an extensions block or message whose length no longer fits a word16, instead of wrapping and under-allocating the ServerHello that a large SCT list makes possible.

Testing

./configure --enable-sct --disable-tls13
./configure --enable-sct --enable-ocspstapling
./configure --enable-sni --enable-opensslextra
./configure --disable-tls --enable-sct

@SparkiDev SparkiDev self-assigned this Nov 25, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:28
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +64 B (+0.0%, 199,268 B / 1,048,576 B, total: 19% used)

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,816 B (+4.9%, 296,396 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

SCT remains enabled in TLS-disabled builds, risking link failures, and TLS 1.2 renegotiation can retain stale SCT state across handshakes.

2 open issues
What changed in this PR

Adds RFC 6962 signed certificate timestamp (SCT) support to wolfSSL’s TLS 1.2 and TLS 1.3 extension handling. The library transports and checks list framing; applications remain responsible for validating timestamps.

Changes:

  • Adds SCT configuration and query APIs, thread-safe context storage, and SNI context-switch handling.
  • Implements protocol-specific SCT placement, generalizes TLS 1.3 certificate-entry extensions, and adds response-length overflow checks.
  • Adds build options, API documentation, regression tests, and CI configurations.
File Description
wolfssl/​ssl.h Declares the four public SCT APIs.
wolfssl/​openssl/​ssl.h Adds BoringSSL-named setter aliases and explains the getter mismatch.
wolfssl/​internal.h Defines SCT state, limits, helpers, and certificate-entry extension guards.
tests/​api/​test_tls13.h Declares and registers the new tests.
tests/​api/​test_tls13.c Tests SCT delivery, framing, lifecycle, callbacks, chains, and placement.
tests/​api/​test_tls_ext.c Tests rejection of custom registration for built-in SCT support.
src/​tls13.c Writes SCT and OCSP certificate-entry extensions using shared buffer handling.
src/​tls.c Implements SCT parsing, serialization, response handling, and length checks.
src/​ssl.c Clears SCT handshake state and handles context switches.
src/​ssl_api_ext.c Implements SCT setters and query APIs.
src/​internal.c Manages SCT initialization, cleanup, and certificate-entry tracking.
doc/​dox_comments/​header_files/​ssl.h Documents SCT APIs, ownership, and validation responsibilities.
configure.ac Adds --enable-sct, bundle defaults, and configuration reporting.
CMakeLists.txt Adds WOLFSSL_SCT, bundle defaults, and crypto-only exclusion.
cmake/​options.h.in Exports the SCT feature macro in generated options.
.github/​configs/​os-check-linux.json Adds SCT-enabled and TLS 1.2-only SCT CI configurations.

Review effort: Balanced

Comment thread configure.ac Resolved
Comment thread src/ssl.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The TLS 1.2 send path can emit an SCT-bearing ServerHello that exceeds the negotiated fragment limit, requiring a fix and handshake coverage for small-fragment requests.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread wolfssl/internal.h Resolved
Comment thread tests/api/test_tls13.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The compatibility aliases narrow size_t lengths before validation, allowing oversized inputs to succeed with only a truncated prefix stored.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread wolfssl/openssl/ssl.h Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Disabling TLS in CMake still advertises SCT without compiling its implementations, causing applications that use the feature to fail to link.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread CMakeLists.txt Resolved
Comment thread src/tls.c Resolved
Add the signed_certificate_timestamp extension for TLS 1.2 and TLS 1.3,
enabled with --enable-sct (CMake WOLFSSL_SCT, macro
HAVE_SIGNED_CERT_TIMESTAMP) and by --enable-all and --enable-tlsx. wolfSSL
carries the SignedCertificateTimestampList between peers; validating the
timestamps is left to the application.

- wolfSSL_CTX_set_signed_cert_timestamp_list() and
  wolfSSL_set_signed_cert_timestamp_list() (BoringSSL names via
  wolfssl/openssl/ssl.h) set the list a server presents. They take a size_t
  length, as BoringSSL's do, so the list is structurally checked and bounded
  by WOLFSSL_MAX_SCT_LIST_SZ before any narrowing. The context
  list is guarded by a mutex since it can be replaced while handshakes run.
  At TLS 1.2 a list that would push the ServerHello past a negotiated
  max_fragment_length is left out rather than the record overflowed.
- wolfSSL_get0_signed_cert_timestamp_list() returns the peer's list and
  wolfSSL_signed_cert_timestamp_requested() reports whether the peer asked.
- A client asks with an empty extension. The server answers in the
  ServerHello at TLS 1.2 (not on resumption) and on the end entity
  CertificateEntry at TLS 1.3. In a CertificateRequest it is accepted and
  ignored.
- A context switch from an SNI callback moves the list with the
  certificate, and a list set from a callback after the ClientHello is
  still answered.
- An application custom extension cannot be registered for type 18 when
  the extension is built in.

Crypto-only and no-TLS builds turn the option off, in configure and CMake
alike, overriding an explicit --enable-sct or -DWOLFSSL_SCT=yes (configure
warns). ChangeLog.md records the feature and that --enable-all and
--enable-tlsx now enable it.

Per-certificate extensions in the TLS 1.3 Certificate message are now built
under WOLFSSL_CERT_ENTRY_EXTS (status_request or SCT, server side), with
WriteCSRToBuffer() becoming WriteCertEntryExts(). Every site that builds,
indexes or frees those buffers uses the same guard, so the send loop no
longer reuses the leaf's entry for every certificate in the chain.

TLSX_GetResponseSize() now refuses an extensions block or message whose
length no longer fits a word16, instead of wrapping and under-allocating the
ServerHello that a large SCT list makes possible.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new TLS wire parsing and certificate-fragment buffer handling require runtime and interoperability validation across SCT-only, OCSP+SCT, and client/server-only builds, which source inspection alone cannot provide.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@julek-wolfssl julek-wolfssl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are again too verbose.

This only implements SCTs from the server to the client. The TLS 1.3 RFC allows the client to send them too. Let's implement that direction too.

Comment thread wolfssl/ssl.h
Comment on lines +1465 to +1466
/* Declared outside the OpenSSL compatibility block: these have their own
* build options and no dependency on it. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think mentioning the compat layer is necessary here. I don't see compat types in these API.

Comment thread wolfssl/internal.h
Comment on lines +4662 to +4667
/* Guards the two fields above. A context's list can be replaced while
* handshakes using that context are running, and the setter frees the
* buffer it is replacing, so the pointer and its length are only read or
* written with this held. Compiles to nothing in a SINGLE_THREADED
* build, where wc_LockMutex() and friends are no-ops. */
wolfSSL_Mutex sctLock;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certs can't be safely replaced in the ctx object while ssl objects exist. Isn't the SCT meant to last the lifetime of the cert?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want to lock the ctx then why introduce a new lock when you could use ctx->ref?

Comment thread wolfssl/internal.h
/* Whether sctLock was initialised. InitSSL_Ctx() can fail before or at
* that point and the caller then frees the context, which must not
* destroy a mutex that was never created. */
byte sctLockInit:1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just use the length?

Comment thread src/ssl_api_ext.c
Comment on lines +944 to +946
#endif /* HAVE_SIGNED_CERT_TIMESTAMP */

#ifdef HAVE_SIGNED_CERT_TIMESTAMP

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary.

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.

4 participants