openssl_x509_verify

(PHP 7 >= 7.4.0, PHP 8)

openssl_x509_verifyVerifies digital signature of x509 certificate against a public key

Beschreibung

openssl_x509_verify(OpenSSLCertificate|string $certificate, OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $public_key): int

openssl_x509_verify() verifies that the certificate certificate was signed by the private key corresponding to public key public_key.

Parameter-Liste

x509

Siehe Schlüssel-/Zertifikatsparameter für eine Auflistung der gültigen Werte.

public_key

OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey()

string - a PEM formatted key, example, "-----BEGIN PUBLIC KEY----- MIIBCgK..."

Rückgabewerte

Returns 1 if the signature is correct, 0 if it is incorrect, and -1 on error.

Changelog

Version Beschreibung
8.0.0 certificate accepts an OpenSSLCertificate instance now; previously, a Ressource of type OpenSSL X.509 was accepted.
8.0.0 public_key accepts an OpenSSLAsymmetricKey or OpenSSLCertificate instance now; previously, a Ressource of type OpenSSL key or OpenSSL X.509 was accepted.

Beispiele

Beispiel #1 openssl_x509_verify() example

<?php
$hostname 
"news.php.net";
$ssloptions = array(
    
"capture_peer_cert" => true
    
"capture_peer_cert_chain" => true
    
"allow_self_signed"=> false
    
"CN_match" => $hostname,
    
"verify_peer" => true,
    
"SNI_enabled" => true,
    
"SNI_server_name" => $hostname,
);
 
$ctx stream_context_create( array("ssl" => $ssloptions) );
$result stream_socket_client("ssl://$hostname:443"$errno$errstr30STREAM_CLIENT_CONNECT$ctx);
$cont stream_context_get_params($result);
$x509 $cont["options"]["ssl"]["peer_certificate"];
$certparsed openssl_x509_parse($x509);

foreach(
$cont["options"]["ssl"]["peer_certificate_chain"] as $chaincert)
{
    
$chainparsed openssl_x509_parse($chaincert);
    
$chain_public_key openssl_get_publickey($chaincert);
    
$r openssl_x509_verify($x509$chain_public_key);   
    if (
$r==1)
    {
        echo 
$certparsed['subject']['CN'];
        echo 
" was digitally signed by ";
        echo 
$chainparsed['subject']['CN']."\n";
    }
}
?>

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

MMOEXP Path of Exile 2 have a chance to contain

In Path Of Exile 2 Trade (https://www.mmoexp.com/Poe-2/Currency.html?fsid=535053)​, mastering crafting materials and unique items is essential f ...

Geschrieben von Specific am 20.05.2026 08:46:25
Forum: Apps und PHP Script Gesuche
MMOEXP Diablo 2: Resurrected features improved visuals

Diablo 2: Resurrected is more than just a visual upgrade of a classic action RPG; it’s a careful preservation of the original game’s dark, imm ...

Geschrieben von Specific am 20.05.2026 08:45:06
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
MMOEXP Ashes of Creation can feel daunting

Ashes of Creation Gold (https://www.mmoexp.com/Aoc/Gold.html)​ is an ambitious MMORPG that promises a living, breathing world where players’ a ...

Geschrieben von Specific am 20.05.2026 08:42:44
Forum: PHP Developer Forum
SELL FULLSsn Dob DL CS CC CVV US UK AUS CA EU ASIA INTER,PASS VBV/BIN/DOB1

VERIFIED CARDER SELLING WU,BANK,PAYPAL,CASHAPP,SKRILL TRANSFER BANK LOGS,DUMPS+PIN,CLONED CARDS​ SELL CCV CANADA FULLZ FRESH SSN DOB WITH DL LI ...

Geschrieben von sellergood11 am 19.05.2026 13:55:53
Forum: Netzwerk &amp; Internet