Skip to content

Stdlib: OpenSSLCertificate / OpenSSLAsymmetricKey / OpenSSLCertificateSigningRequest — PHP 8.4 ext/openssl resource→object missing (openssl.stub.php) #7268

Closed

Description

@PurHur

Category

stdlib

Problem

PHP 8.4 migrated ext/openssl resources to OpenSSLCertificate, OpenSSLAsymmetricKey, and OpenSSLCertificateSigningRequest objects (php-src ext/openssl/openssl.stub.php). This compiler has partial openssl stubs (#3324) but class_exists() is false for all three types; openssl_x509_read() and key APIs cannot match Zend signatures or instanceof checks.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
foreach ([\"OpenSSLCertificate\", \"OpenSSLAsymmetricKey\", \"OpenSSLCertificateSigningRequest\"] as \$c) {
    echo \$c, \": \", class_exists(\$c, false) ? \"yes\" : \"no\", PHP_EOL;
}
"'
# all no
<?php
$pem = "-----BEGIN CERTIFICATE-----\nMIIB…\n-----END CERTIFICATE-----\n"; // minimal harness PEM
$cert = openssl_x509_read($pem); // undefined today (#6274)
var_export($cert instanceof OpenSSLCertificate);
Runtime OpenSSLCertificate class openssl_x509_read() return type
Zend PHP 8.4+ registered OpenSSLCertificate object
bin/vm.php missing undefined function / resource shim

Scope (this repo)

Path Work
ext/openssl/BuiltinClasses.php Register the three object classes (internal, not user-extendable)
ext/openssl/*.php VM wrappers holding native cert/key pointers
#6274 / #6295 Return objects from openssl_x509_read(), openssl_pkey_get_*()
Tests test/unit/OpenSslObjectTypesTest.php

PHP-in-PHP: object handlers in ext/openssl/; OpenSSL FFI stays thin.

php-src-strict: passing a backed enum case where Zend expects OpenSSLCertificate must TypeError.

Done when

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter OpenSslObjectTypes'

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 7, 2026
  2. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    claim: agent-worker-c — starting this run

  3. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    Merged via #8294.

    Verification

    • Issue repro: all three classes report `class_exists(..., false) === yes` on VM
    • `vendor/bin/phpunit --filter OpenSslObjectTypes` → OK (4 tests, 12 assertions)
    • `openssl_x509_read($pem)` returns `OpenSSLCertificate`; invalid PEM → `false`; enum operand → `TypeError` (php-src-strict)
    • `openssl_free_key()` registered as deprecated noop

    Follow-ups (separate issues): `openssl_pkey_get_*()` returning `OpenSSLAsymmetricKey` (#6295), CSR object construction.

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