KontoCloud

Help / Rules and tools

Local signer

Signing e-invoices, MPIN and contracts with a USB token or a local .p12, without the private key going to the server.

On this page

With the local signer, the private key stays on your USB token or in your .p12 file. The server keeps only the public certificate and verifies every signature. When the legal entity has a local certificate set, the following go through the signer:

  • every request to the UJP for e-Invoice, including automatic resending and sending offline e-invoices;
  • the signed file and the sending of MPIN to e-PDD;
  • the signature of an agreement with Sign in KontoCloud and with Sign with the certificate when signing in order.

The signer is the KontoCloud desktop app or the kc signer run command from the CLI. No browser add-on is needed. The signer connects to the server on its own, so it also works when you use the web app. In the web app the screen says so too: “In the browser, signing is done by the KontoCloud desktop app (Signer) or “kc signer run” on the computer with the token.”

What you need

  • A certificate of the legal entity with an RSA key. e-Invoice is signed with RS256 (JWS), and MPIN with RSA-SHA512 (RS512, XAdES). The same RSA certificate works for both.
  • For a USB token: the token driver from the issuer (PKCS#11 module), for example SafeNet Authentication Client on Windows and macOS or OpenSC on Linux.
  • The KontoCloud desktop app or the kc CLI on the computer where the token is.

Setting the public certificate

The administrator sets the public certificate of the legal entity. This is needed only once, in one of three ways.

From the web or desktop app, with a file: in Settings → Company, in the Local signer section, click Set public certificate (.cer, .pem) and choose a .cer, .crt, .pem or .der file. The message “Local certificate set” confirms that it is set.

From the desktop app, from the token or .p12: after you choose the certificate (see below), click Use for this legal entity.

From the CLI: kc signer register with --pkcs11, --p12 <file> or --cert <file>.

The server refuses the certificate if:

  • the key is not RSA (“The UJP requires an RSA key (RS256)”);
  • the certificate is not valid today (“The certificate is not valid today”);
  • the file is not a certificate (“This is not an X.509 certificate”).

As with the server certificate, the EDB in the certificate must be the EDB of the legal entity, and an expired certificate is not accepted (error KC261 from the database).

Starting the signer in the desktop app

  1. Choose a source: USB token or Local .p12.
  2. For a token: check the PKCS#11 module. The field is filled in with a known module if one is found, for example /usr/local/lib/libeTPkcs11.dylib. Click Read certificates and choose the Token certificate. Only RSA certificates are shown. If there are none, you will see the message “No token with an RSA certificate is plugged in”.
  3. For .p12: click Choose a .p12 and choose the file.
  4. Enter the PIN (for a token) or the Certificate password (for .p12).
  5. Click Start signer.

While it runs, the app shows “Signer running · signed: …” and the subject of the certificate. If you have chosen another legal entity, “(for another legal entity)” is shown next to it. Stop signer stops it.

The e-Invoice settings card says “Signer connected” or “Signer not connected”, with the name of the signer and when it last checked in.

Signature request

When the server needs a signature, the signer shows the Signature request window. It contains:

  • what is being signed and the type of request: Sending to UJP, Decision on a received invoice, Reading from UJP or Contract signature;
  • who is asking and when;
  • Content being signed, which opens with a click.

Click Sign or Decline.

Reading from the UJP (status, PDF, incoming invoices) is signed automatically, without asking. All other requests need your confirmation.

MPIN is shown as Sending to UJP, with the description “MPIN for MM.YYYY (N employees)”. This applies to both Signed XML and Send to UJP in MPIN to e-PDD. An agreement signature when signing in order has the description “Agreement no. …: …”.

The request is also refused if it is for a different certificate than the one in the signer, or if you stop the signer while it is waiting.

What the server does

  • If the signer has not checked in within the last 40 seconds, the server considers it not connected. The action is then refused with the message “The local signer is not connected — plug in the token and open the KontoCloud desktop app (Signer) or run “kc signer run””. Nothing goes to the UJP.
  • A request with no answer for 120 seconds expires.
  • Every signature is verified with the public key of the certificate that was set, using the algorithm of the request (RS256 or RS512). A signature with another key is refused and nothing goes to the UJP.
  • When you sign out of the desktop app, the signer stops and the key is wiped from memory.

Note: without the encryption key (KC_SECRET_KEY) the server does not accept a .p12 at all. Then the local signer is the only way to sign.

Signature log

Every signature with the local certificate, including the MPIN signatures, is recorded and cannot be changed or deleted. The purpose, the SHA-256 of what was signed and of the signature, who requested it and who signed are recorded. Only the administrator or the accountant can make a record. The database accepts only a signature with the legal entity’s valid local certificate (KC268). The records go into the audit trail and the archive.

You can see the records in e-Invoice (UJP), sub-tab Signatures: “Every signature made with the local certificate: who requested it, who signed and the SHA-256 of what was signed.” Columns: Time, What was signed, Requested by, Signed by; SHA-256 is hidden. If there are no records, it says “No local signatures.”

Signer from the CLI

Command What it does
kc signer certs [--pkcs11 <module>] shows the certificates on the plugged-in tokens, without a PIN
kc signer register sets the public certificate (--pkcs11 [module] --slot … --id <CKA_ID>, --p12 <file> or --cert <file>)
kc signer run starts the signer, with the same arguments for the key
kc signer status status of the signer
kc signer log signature log

With run, --yes signs without asking, and --max N stops the signer after N signatures. The PIN is taken from KC_TOKEN_PIN or entered in the terminal, and the .p12 password from KC_CERT_PASSWORD.

Important: --yes signs everything without confirmation. Use it only on a computer you trust.

Something unclear or wrong? Write to us at [email protected].