Guest mode. You can read posts without signing up. Comments, ratings, job contacts and your own posts open after you sign up and accept the rules. What is Kommit →

📚 GuideЭЦП и NCALayer для разработчиковИнтеграция · часть 3 из 3
Guide contents
Интеграция
  1. ЭЦП и NCALayer, часть 2: подпись в браузере через NCALayer
  2. ЭЦП и NCALayer, часть 3: проверка подписи на сервере — цепочка, отзыв, ИИН и БИН
Редакция КоммитРедакция портала
commit 8a05569 · 19 days ago

EDS and NCALayer, part 3: signature verification on the server — chain, recall, IIN, and BIN

🌐 Machine-translated from Russian. Show original

In this part:

Verification options#

OptionProsCons
Validation service (for example, the open NCANode project — a server with REST API based on cryptolibraries for NUC keys)you don't need to understand cryptography, validation is readya separate service and needs to be updated
The cryptolibrary in its applicationwithout external dependenciessupport for national algorithms and neat implementation of all

For most projects, it is easier to raise the validation service in your contour (the Docker container next to the application) and call it over HTTP.

What to check#

  1. Integrity: the signature matches the data. For a detached signature — pass the source data along with the signature.
  2. Trust chain for root certificates of the NUC RK. Update root and intermediate certificates.
  3. The certificate is valid at the time of signing.
  4. Revocation — OCSP or CRL. Without this verification, the signature of the dismissed director or the stolen key will be "valid."
  5. Key assignment via Key Usage / Extended Key Usage certificate: does it allow document signing. Do not accept old AUTH keys for document signing.
  6. Subject: The signatory's IIN and, for legal entities, the organization's BIN match the expected ones.
  7. Authority: for legal entities, verify that the signer has the right to sign the document on behalf of the organization (manager or authorized person) — this is a business rule of your system.

Example handler#

// псевдокод: verify() — вызов вашего сервиса проверки подписи
app.post("/api/documents/:id/sign", async (req, res) => {
  const doc = await db.document.findUniqueOrThrow({ where: { id: req.params.id } });
  const r = await verify({ cms: req.body.cms, data: doc.contentBase64, checkRevocation: true });

  if (!r.valid) return res.status(400).json({ error: "Подпись недействительна" });
  if (!r.signer.keyUsages.includes("SIGNATURE")) return res.status(400).json({ error: "Нужен ключ подписания" });
  if (r.signer.bin !== doc.counterpartyBin) return res.status(403).json({ error: "Подписант не из той организации" });

  await db.signature.create({
    data: { documentId: doc.id, cms: req.body.cms, iin: r.signer.iin, bin: r.signer.bin,
            certSerial: r.signer.serial, signedAt: new Date() },
  });
  res.json({ ok: true });
});

Storing signed documents#

  • Keep the original document, signature , and verification result with the verification time.
  • Keep your signatory certificate — it may be difficult to obtain it years later.
  • For long-term retention, consider a timestamp (TSP): it confirms that the signature existed before the certificate expired.

1C#

In 1C configurations for Kazakhstan, working with the EDS of the NCC is built into standard mechanisms for exchanging with government systems. For your own improvements, use the same configuration mechanisms rather than custom cryptography.

Typical errors#

  • Only the "signature is correct" is checked, without a review or chain.
  • Accept the old AUTH key for document signing — check the purpose in the certificate, not the file name.
  • Bins are not checked — the signature of "some organization" is taken as the counterparty's signature.
  • They only keep the fact "signed," without the signature itself and the certificate.

On where EDS is needed in government systems — the series "Integrations with Kazakhstan's State Systems."

Comments 00 участников · 1 гость🔒 Rate and discuss after signing up

Comments · 0

No comments yet.Sign in to comment, rate and see all comments.