mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2025-04-18 19:43:12 +03:00
Поиск сертификата в объеденённом списке сертификатов из личного хранилища и из закрытого ключа
This commit is contained in:
parent
33f5941e58
commit
937da83bb4
@ -1,20 +1,29 @@
|
||||
import { Certificate } from './certificate';
|
||||
import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded';
|
||||
import { getUserCertificates } from './getUserCertificates';
|
||||
import {Certificate} from './certificate';
|
||||
import {_afterPluginsLoaded} from '../helpers/_afterPluginsLoaded';
|
||||
import {getCertificates} from "./getCertificates";
|
||||
import {getAllCertificates} from "./getAllCertificates";
|
||||
|
||||
/**
|
||||
* Возвращает сертификат по отпечатку
|
||||
*
|
||||
* @param thumbprint - отпечаток сертификата
|
||||
* @param validOnly - проверять сертификаты по дате и наличию приватного ключа
|
||||
* @returns сертификат
|
||||
*/
|
||||
export const getCertificate = _afterPluginsLoaded(
|
||||
async (thumbprint: string): Promise<Certificate> => {
|
||||
async (thumbprint: string, validOnly: boolean = true): Promise<Certificate> => {
|
||||
if (!thumbprint) {
|
||||
throw new Error('Отпечаток не указан');
|
||||
}
|
||||
|
||||
const availableCertificates: Certificate[] = await getUserCertificates();
|
||||
let availableCertificates: Certificate[];
|
||||
|
||||
if (validOnly) {
|
||||
availableCertificates = await getCertificates();
|
||||
} else {
|
||||
availableCertificates = await getAllCertificates();
|
||||
}
|
||||
|
||||
const foundCertificate: Certificate = availableCertificates.find((cert) => cert.thumbprint === thumbprint);
|
||||
|
||||
if (!foundCertificate) {
|
||||
|
Loading…
Reference in New Issue
Block a user