Skip to content

Stdlib: openssl_pkey_export_to_file() missing after openssl_pkey_export (ext/openssl/openssl.c) #20287

Closed

Description

@PurHur

Category

stdlib · php-src-strict · ext/openssl key PEM file export (extends #6295)

Problem

openssl_pkey_export() writes PEM to a by-ref string, but Zend’s openssl_pkey_export_to_file() is not registered — apps that persist keys to disk (common deploy/bootstrap pattern) hit a fatal.

Repro Zend 8.2+ VM (2026-07-17)
function_exists('openssl_pkey_export_to_file') true false
openssl_pkey_export_to_file($key, $path) true + PEM file fatal undefined function

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r "var_export(function_exists(\"openssl_pkey_export_to_file\")); echo PHP_EOL;"'

Expected: true. Today: false.

Zend smoke: openssl_pkey_new → openssl_pkey_export_to_file($key, '/tmp/k.pem') → file starts with -----BEGIN.

Done when (php-src-strict)

  • Function registered; writes PEM matching openssl_pkey_export content
  • Failure paths (unwritable path) match Zend bool + warning
  • Optional passphrase arg parity with stub
  • Compliance .phpt under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

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 Jul 17, 2026
  2. PurHur commented on Jul 18, 2026

    @PurHur
    OwnerAuthor

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

    Trust probe (before implement):

    • host docker info OK; vendor present
    • make bootstrap-selfhost-link → OK (/compiler/build/selfhost)
    • php script/bootstrap-inventory.php --check → red (doc drift on ext/standard/JitGmmktime.php / JitMktime.php class method counts — unrelated to openssl; master doc lag)
    • ./script/release-readiness.sh --json — still running; will note user_release_ready when finished

    Implementing openssl_pkey_export_to_file (#20287) toward php-src-strict.

  3. PurHur commented on Jul 18, 2026

    @PurHur
    OwnerAuthor

    merged via #20329

    Verification

    • php bin/vm.php -r 'var_export(function_exists("openssl_pkey_export_to_file"));' → true
    • php bin/vm.php test/repro/openssl_pkey_export_to_file_20287.php → ok (plain PEM match + passphrase encrypt/load)
    • vendor/bin/phpunit --filter openssl_pkey_export_to_file → OK (2)
    • inventory 5529/5529; north-star5-verify-fast OK after rebase

    php-src-strict: ext/openssl/openssl_pkey_export_to_file.php + passphrase write via VmOpensslPkeyNative::writePrivateKeyPem (3DES).

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions