Total Complexity | 4 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class Certificate |
||
13 | { |
||
14 | /** |
||
15 | * The pattern that the contents of a certificate should adhere to |
||
16 | */ |
||
17 | public const PUBLIC_KEY_PATTERN = '/^-----BEGIN CERTIFICATE-----([^-]*)^-----END CERTIFICATE-----/m'; |
||
18 | public const PRIVATE_KEY_PATTERN = '/^-----BEGIN RSA PRIVATE KEY-----([^-]*)^-----END RSA PRIVATE KEY-----/m'; |
||
19 | |||
20 | |||
21 | |||
22 | /** |
||
23 | * @param string $certificate |
||
24 | * @param string $pattern |
||
25 | * |
||
26 | * @return bool |
||
27 | */ |
||
28 | public static function hasValidStructure(string $certificate, string $pattern = self::PUBLIC_KEY_PATTERN): bool |
||
31 | } |
||
32 | |||
33 | |||
34 | /** |
||
35 | * @param string $X509CertificateContents |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | public static function convertToCertificate(string $X509CertificateContents): string |
||
44 | } |
||
45 | |||
46 | |||
47 | /** |
||
48 | * @param string $key The PEM-encoded key |
||
49 | * @param string $pattern The pattern to use |
||
50 | * @return string The stripped key |
||
51 | */ |
||
52 | public static function stripHeaders(string $key, string $pattern = self::PUBLIC_KEY_PATTERN) |
||
64 |