mirror of
https://github.com/crypto-pro-web/crypto-pro-php.git
synced 2025-01-18 11:25:50 +03:00
Пример вывода списка сертификатов
This commit is contained in:
parent
43fcb9f061
commit
404e02594e
56
examples/list_of_all_valid_certificates.php
Executable file
56
examples/list_of_all_valid_certificates.php
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once dirname(__FILE__, 2) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$certificates = \Webmasterskaya\CryptoPro\CryptoPro::getUserCertificates();
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
print $e->getMessage() . PHP_EOL;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($certificates as $certificate)
|
||||||
|
{
|
||||||
|
$owner = $certificate->getOwnerInfo();
|
||||||
|
|
||||||
|
print PHP_EOL;
|
||||||
|
print '==================================================' . PHP_EOL;
|
||||||
|
print PHP_EOL;
|
||||||
|
|
||||||
|
print $certificate->name . PHP_EOL;
|
||||||
|
|
||||||
|
print 'Отпечаток:' . PHP_EOL;
|
||||||
|
print "\t" . $certificate->thumbprint . PHP_EOL;
|
||||||
|
|
||||||
|
print 'Подписант:' . PHP_EOL;
|
||||||
|
foreach ($owner as $item)
|
||||||
|
{
|
||||||
|
if ($item['RDN'] == 'CN' || $item['RDN'] == 'UN')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\t" . $item['title'] . ': ' . $item['description'] . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
print 'Область использования ключа:' . PHP_EOL;
|
||||||
|
foreach ($certificate->getDecodedExtendedKeyUsage() as $oid => $title)
|
||||||
|
{
|
||||||
|
print "\t" . $title . ' (OID: ' . $oid . ')' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$algorithm = $certificate->getAlgorithm();
|
||||||
|
print 'Алгоритм сертификата:' . PHP_EOL;
|
||||||
|
print "\t" . $algorithm['algorithm'] . ' (OID: ' . $algorithm['oid'] . ')' . PHP_EOL;
|
||||||
|
|
||||||
|
print 'Срок действия сертификата:' . PHP_EOL;
|
||||||
|
print "\t" . 'c: ' . $certificate->validFrom . PHP_EOL;
|
||||||
|
print "\t" . 'до: ' . $certificate->validTo . PHP_EOL;
|
||||||
|
|
||||||
|
print PHP_EOL;
|
||||||
|
print '==================================================' . PHP_EOL;
|
||||||
|
print PHP_EOL;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user