-
Notifications
You must be signed in to change notification settings - Fork 4
/
parse_cert.php
45 lines (40 loc) · 1.29 KB
/
parse_cert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once __DIR__.'/../vendor/autoload.php';
$t1 = microtime(true);
$certificate = \Adapik\CMS\Certificate::createFromContent(file_get_contents('php://stdin'));
$t2 = microtime(true);
echo 'Parsed in: ' . ($t2 - $t1) . 's';
echo "\n";
echo 'Issuer: ' . (string) $certificate->getIssuer();
echo "\n";
echo 'Subject: ' . (string) $certificate->getSubject();
echo "\n";
echo 'Valid Not Before: ' . $certificate->getValidNotBefore();
echo "\n";
echo 'Valid Not After: ' . $certificate->getValidNotAfter();
echo "\n";
echo 'Certificate subjectKeyIdentifier: ' . $certificate->getSubjectKeyIdentifier();
echo "\n";
echo 'Certificate authorityKeyIdentifier: ' . $certificate->getAuthorityKeyIdentifier();
echo "\n";
echo 'OCSP Uri: ' . implode(',', $certificate->getOcspUris());
echo "\n";
echo 'CA: ' . ($certificate->isCa() ? 'true' : 'false');
echo "\n";
echo 'Certificate Policies:';
echo "\n";
foreach ($certificate->getCertPolicies() as $certPolicy) {
echo "\t- ".$certPolicy;
echo "\n";
}
echo 'Extended Key Usage:';
echo "\n";
foreach ($certificate->getExtendedKeyUsage() as $keyUsage) {
echo "\t- ".$keyUsage;
echo "\n";
}
$t3 = microtime(true);
echo 'Total: ' . ($t3 - $t1) . 's';
echo "\n";
echo 'Memory Usage: ' . memory_get_peak_usage(true) . ' bytes';
echo "\n";