Skip to content

Stdlib: openssl_x509_verify() — certificate signature verification missing (ext/openssl/x509.c) #6595

Closed

Description

@PurHur

Category

stdlib

Problem

openssl_x509_verify() validates an X.509 certificate against a public key / CA material. Zend registers it in ext/openssl; this compiler has partial OpenSSL coverage (#3324, #6524, #6559) but openssl_x509_verify() is not registered — function_exists('openssl_x509_verify') is false on bin/vm.php.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(function_exists(\"openssl_x509_verify\"));"
php -r "var_export(function_exists(\"openssl_x509_verify\"));"
'
Runtime Result
Zend PHP 8.2 (openssl ext) true
bin/vm.php false

Once registered, verify against a self-signed PEM fixture:

$cert = openssl_x509_read(file_get_contents('test/fixtures/openssl/selfsigned.pem'));
$key  = openssl_pkey_get_public($cert);
var_export(openssl_x509_verify($cert, $key)); // Zend: 1

(Use an existing repo fixture or add minimal PEM under test/fixtures/openssl/.)

Scope (this repo)

Component Path Notes
VM builtin new ext/openssl/openssl_x509_verify.php + module registration Delegate to OpenSSL via thin ABI or documented host path for bootstrap v1
Type errors VmString::coerceStringBuiltinArg() guards Enum-case cert/key operands must TypeError (php-src-strict)
JIT/AOT VM-only v1 acceptable Document in capability matrix

Prefer PHP implementation in ext/openssl/; avoid permanent C-only builtins unless migrating out of C.

Done when

  • function_exists('openssl_x509_verify') is true on VM
  • Self-signed fixture returns 1; tampered cert or wrong key returns 0 or false matching Zend
  • Enum-case operand raises catchable TypeError, not LogicException
  • Compliance: test/compliance/cases/stdlib/openssl_x509_verify.phpt green on VM

Strictness: php-src-strict

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 6, 2026
  2. PurHur commented on Jul 13, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run

  3. PurHur commented on Jul 13, 2026

    @PurHur
    OwnerAuthor

    Merged via #18528

    Verification (VM, libcrypto FFI):

    • function_exists('openssl_x509_verify') → yes
    • Self-signed fixture PEM: openssl_x509_verify($cert, $cert) → 1
    • Wrong public key PEM → 0
    • Enum-case public key operand → TypeError
    • ./vendor/bin/phpunit --filter openssl_x509_verify → OK
    • php script/bootstrap-inventory.php --check → OK 4747/4747
    • ./script/ci-fast.sh → exit 0

    php-src ref: ext/openssl/x509.c. PHP impl: ext/openssl/openssl_x509_verify.php, VmOpensslX509Native::verifyCertificatePem().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions