mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
implement identity model
This commit is contained in:
parent
7e150ebea2
commit
47b7344e2e
3 changed files with 195 additions and 0 deletions
40
src/Interface/Model/Identity.php
Normal file
40
src/Interface/Model/Identity.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue