PHP 8.3.4 Released!

openssl_pkey_get_private

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

openssl_pkey_get_privateLiefert einen privaten Schlüssel

Beschreibung

openssl_pkey_get_private(OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key, ?string $passphrase = null): OpenSSLAsymmetricKey|false

openssl_pkey_get_private() parst private_key und bereitet ihn zur Verwendung durch andere Funktionen vor.

Parameter-Liste

private_key

Als private_key kann angegeben werden:

  1. Eine Zeichenkette im Format file://path/to/file.pem. Die angegebene Datei muss ein PEM-kodiertes Zertifikat und/oder einen privaten Schlüssel enthalten.
  2. Ein privater Schlüssel im PEM-Format.

passphrase

Der optionale Parameter passphrase muss angegeben werden, falls der Schlüssel selbst verschlüsselt ist (durch eine Passphrase geschützt).

Rückgabewerte

Gibt bei Erfolg eine OpenSSLAsymmetricKey-Instanz zurück oder false, wenn ein Fehler auftritt.

Changelog

Version Beschreibung
8.0.0 Bei Erfolg gibt diese Funktion nun eine OpenSSLAsymmetricKey-Instanz zurück; vorher wurde eine Ressource vom Typ OpenSSL-Schlüssel zurückgegeben.
8.0.0 private_key akzeptiert nun eine OpenSSLAsymmetricKey- oder OpenSSLCertificate-Instanz; vorher wurde eine Ressource vom Typ OpenSSL-Schlüssel oder OpenSSL X.509 akzeptiert.
8.0.0 passphrase ist nun ein Nullable-Typ.
add a note

User Contributed Notes 2 notes

up
23
kristof1 at mailbox dot hu
9 years ago
It's actually "file://key.pem" when you want to give a relative path using unix systems. It will be three '/' in case of absolute path (e.g "file:///home/username/..."). But this path consists of two '/' originated from "file://" and one '/' from the fact that home is a subfolder of the unix filesystem's root directory ("/home/username/..."). This two part will be concatenated and you will get three '/' characters following each other.

So you only have to concatenate "file://" with an existing path string in every case.
up
-23
pablo dot siciliano at gmail dot com
3 years ago
Hi.

If this function not work with pathname try with a file_get_contents of a key file.
To Top