Skip to content

GetCertificate

Finds a certificate based on the given context.

1
$Crypto.GetCertificate(cert: CertificateContext):( Certificate | `"null"` )

Loads a certificate from PFX content.

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

Parameters

CertificateContext cert
    The certificate context to use when searching for the certificate.

string password
    The password of the PFX content.

Returns

The certificate if found; otherwise, null. All certificates found in the PFX content.

Remarks

If multiple certificates are found, the first one is returned. If no certificate is found, null is returned. An exception is thrown if the PKCS11 library or PFX file is not found or fails to load.

Finding a certificate from a list

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

Loading a certificate from a 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 a certificate from a PFX file

1
2
var certificates = $Crypto.GetCertificate('base64 encoded pfx content', 'password');
var cert = certificates[0];

See Also