Skip to content

GetCertificate

Finds a certificate by given context

1
$Crypto.GetCertificate(cert: CertificateContext):Certificate

Loads certificate from PFX content

1
$Crypto.GetCertificate(cert: string, password: string):Certificate

Parameters

CertificateContext cert
    Certificate context to find certificate

string password
    Password of PFX content

Returns

Certificate if found, otherwise null Array of certificates found in PFX content

Remarks

If multiple certificates found, first one is returned.
If no certificate found, null is returned.
Throws error exception if PKCS11 library or PFX file is not found or failed to load.

Find a certificates from list

1
2
3
4
5
6
var cert = $Crypto.GetCertificate({
    Filter: {
        CommonName: 'The Name'
        // SerialNumber : '1234'
    }
});

Load certificate from PKCS11 library

1
2
3
4
5
6
7
8
var cert = $Crypto.GetCertificate({
    Filter: {
        CommonName: 'The Name'
        // SerialNumber : '1234'
    },
    Pin: '1111',
    Library: '<path to PKCS11 library>'
});

Load certificate from PFX file

1
var cert = $Crypto.GetCertificate('base64 encoded pfx content', 'password');