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