<?php openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false
<?php if ($pubkey === false) { throw new \RuntimeException('Failed to retrieve the public key from certificate'); } $pubkeydetails = openssl_pkey_get_details($pubkey); $pubkeypem = $pubkeydetails['key']; $start = '-----BEGIN PUBLIC KEY-----';