Skip to content

ts: refactor OpenSSL::Timestamp::Factory#create_timestamp - #1148

Merged
rhenium merged 1 commit into
ruby:masterfrom
rhenium:ky/ts-refactor-tsfac-create-ts
Nov 10, 2026
Merged

rhenium merged 1 commit into
ruby:masterfrom
rhenium:ky/ts-refactor-tsfac-create-ts

Conversation

@rhenium

@rhenium rhenium commented Nov 10, 2026

Copy link
Copy Markdown
Member

Wrap everything in a big rb_protect() to simplify error handling and cleanup. This also fixes potential issues:

  • Missing error check of TS_RESP_CTX_set_signer_key()
  • Missing error check of TS_RESP_CTX_set_certs()
  • Missing error check of TS_RESP_CTX_set_def_policy()
  • Memory leak when rb_ary_new_capa() raises an exception

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new validation paths use rb_raise, leaving TimestampError#errors nil and OpenSSL errors queued, which can break existing error handlers.

1 open issue
What changed in this PR

Refactors OpenSSL::Timestamp::Factory#create_timestamp to simplify exception handling and native-resource cleanup during timestamp generation.

Changes:

  • Consolidates response creation under one rb_protect call with centralized cleanup.
  • Adds error checks for signer-key, certificate-stack, and default-policy setters.
File Description
ext/​openssl/​ossl_ts.c Introduces shared creation state and a protected helper, updates callbacks, and centralizes resource cleanup.

Review effort: Max

Comment thread ext/openssl/ossl_ts.c Resolved
Wrap everything in a big rb_protect() to simplify error handling and
cleanup. This also fixes potential issues:

  - Missing error check of TS_RESP_CTX_set_signer_key()
  - Missing error check of TS_RESP_CTX_set_certs()
  - Missing error check of TS_RESP_CTX_set_def_policy()
  - Memory leak when rb_ary_new_capa() raises an exception
@rhenium
rhenium force-pushed the ky/ts-refactor-tsfac-create-ts branch from 411011d to c5c78d0 Compare November 10, 2026 17:07
@rhenium
rhenium merged commit 18b8a70 into ruby:master Nov 10, 2026
48 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