Skip to content

Sign

Signs the given requests using the specified certificate.

1
$Crypto.Sign(cert: `CommonName` : string

The common name of the certificate.

SerialNumber : string
The serial number of the certificate.

Logout() : void
Logs out from the PKCS11 device.

TryLogin(pin: string) : string
Tries to log in to the PKCS11 device with the given PIN., request: SignatureRequest):SignatureResult

Signs the request with a matching certificate filter.

1
$Crypto.Sign(input: `Filter` : [CertificateFilter](./CertificateFilter/index.md)

The filter to use when searching for a certificate.

Library : string
The path to the PKCS11 library.

Pin : string
The PIN number of the certificate, if stored in a PKCS11 library.

Requests : Array<SignatureResource>
An array of resources to be signed.):SignatureResult

Parameters

CommonName : string
The common name of the certificate.

SerialNumber : string
The serial number of the certificate.

Logout() : void
Logs out from the PKCS11 device.

TryLogin(pin: string) : string
Tries to log in to the PKCS11 device with the given PIN. cert
    The certificate to use for signing.

SignatureRequest request
    The request to sign.

Filter : CertificateFilter
The filter to use when searching for a certificate.

Library : string
The path to the PKCS11 library.

Pin : string
The PIN number of the certificate, if stored in a PKCS11 library.

Requests : Array<SignatureResource>
An array of resources to be signed. input
    The request to sign, including the certificate filter and signing options.

Returns

The signature result. The signature result.

Remarks

Signs plain text with a certificate

1
2
3
4
var cert = $Crypto.GetCertificate('base64 encoded pfx content', 'password');
var result = $Crypto.Sign(cert, {
    Requests: [{ Source: 'Hello World', Format: 'Cades', Level: 'BES' }]
});

Signs plain text with a certificate from a PKCS11 library

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var cert = $Crypto.GetCertificate({
   Filter: {
        CommonName: 'The Name'
        // SerialNumber : '1234'
    },
    Pin: '1111',
    Library: '<path to PKCS11 library>',
});
var result = $Crypto.Sign(cert, {
    Requests: [{ Source: 'Hello World', Format: 'Cades', Level: 'BES' }]
});

Signs a file with a certificate from a PKCS11 library

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var cert = $Crypto.GetCertificate({
   Filter: {
        CommonName: 'The Name'
        // SerialNumber : '1234'
    },
    Pin: '1111',
    Library: '<path to PKCS11 library>',
});
var result = $Crypto.Sign(cert, {
    Requests: [{ SourceFile: $Xml.Evaluate('MyFile'), Format: 'Cades', Level: 'BES' }]
});

Sign a request with a certificate from a PKCS11 library

1
2
3
4
5
6
7
8
9
var result = $Crypto.Sign({
    Filter: {
        CommonName: 'The Name'
        // SerialNumber : '1234'
    },
    Pin: '1111',
    Library: '<path to PKCS11 library>',
    Requests: [{ Source: 'Hello World', Format: 'Cades', Level: 'BES' }]
});

See Also