Skip to content

Stdlib: openssl_pkey_new/openssl_pkey_get_private/openssl_pkey_export — key pair API missing (ext/openssl/xp.c) #6295

Closed

Description

@PurHur

Category

stdlib

Problem

#3324 tracks encrypt/decrypt/sign/verify. Asymmetric key lifecycle builtins — generating key pairs, loading PEM private keys, exporting to PEM/DER — are still missing. JWT, TLS client certs, and openssl_sign() workflows need openssl_pkey_new() / openssl_pkey_get_private() / openssl_pkey_export().

function_exists('openssl_pkey_new') → false on VM.

php-src reference

Repro (failure today)

<?php
var_export(function_exists('openssl_pkey_new'));
echo "\n";
$key = openssl_pkey_new(['private_key_bits' => 512, 'private_key_type' => OPENSSL_KEYTYPE_RSA]);
var_export($key !== false);
echo "\n";
if ($key) {
    openssl_pkey_export($key, $pem);
    echo str_contains($pem, 'BEGIN') ? "pem-ok\n" : "pem-fail\n";
    openssl_pkey_free($key);
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php repro.php
'
Runtime function_exists('openssl_pkey_new') Keygen
Zend + openssl true resource/object + PEM export
bin/vm.php false undefined function

Scope (this repo)

Path Work
ext/openssl/ or extend #3324 module openssl_pkey_*.php builtins
VM OpenSSL key resource / OpenSSLAsymmetricKey object (PHP 8.0+)
Tests test/compliance/cases/stdlib/openssl_pkey_new.phpt
JIT/AOT VM v1

Coordinate with #6228 introspection helpers (openssl_get_md_methods, etc.).

Done when

Verification

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

Links

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #6295)

  3. PurHur commented on Jul 5, 2026

    @PurHur
    OwnerAuthor

    Merged via #16593.

    Verification:

    php bin/vm.php test/repro/maintainer_gap_openssl_pkey_lifecycle.php  # ok
    vendor/bin/phpunit test/compliance/VMTest.php --filter openssl_pkey_lifecycle  # OK
    ./script/ci-fast.sh  # exit 0

    RSA keygen + PEM export/load + sign round-trip green on VM (libcrypto FFI).

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