mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
50 lines
No EOL
1.2 KiB
PHP
50 lines
No EOL
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Yggverse\Yoda\Interface\Model;
|
|
|
|
use \OpenSSLAsymmetricKey;
|
|
use \OpenSSLCertificate;
|
|
use \OpenSSLCertificateSigningRequest;
|
|
|
|
/*
|
|
* Certificate-based Identity API
|
|
*
|
|
*/
|
|
interface Identity
|
|
{
|
|
public const CSR_SIGN_DAYS = 365;
|
|
|
|
public const PRIVATE_KEY_BITS = 2048;
|
|
public const PRIVATE_KEY_TYPE = OPENSSL_KEYTYPE_RSA;
|
|
|
|
// Generate new private key
|
|
public static function new(
|
|
int $bits = self::PRIVATE_KEY_BITS,
|
|
int $type = self::PRIVATE_KEY_TYPE
|
|
): OpenSSLAsymmetricKey;
|
|
|
|
// Generate certificate signing request (CSR)
|
|
public static function csr(
|
|
OpenSSLAsymmetricKey $key
|
|
): OpenSSLCertificateSigningRequest;
|
|
|
|
// Sign the CSR
|
|
public static function sign(
|
|
OpenSSLCertificateSigningRequest $csr,
|
|
OpenSSLCertificate|OpenSSLAsymmetricKey|array|string $key,
|
|
OpenSSLCertificate|string|null $crt = null, // self-signed
|
|
int $days = self::CSR_SIGN_DAYS
|
|
): OpenSSLCertificate;
|
|
|
|
// Read certificate
|
|
public static function read(
|
|
OpenSSLCertificate|string $crt
|
|
): OpenSSLCertificate;
|
|
|
|
// Dump certificate
|
|
public static function parse(
|
|
OpenSSLCertificate|string $crt
|
|
): array;
|
|
} |