
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#
| Option | Pros | Cons |
|---|---|---|
| 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 ready | a separate service and needs to be updated |
| The cryptolibrary in its application | without external dependencies | support 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#
- Integrity: the signature matches the data. For a detached signature — pass the source data along with the signature.
- Trust chain for root certificates of the NUC RK. Update root and intermediate certificates.
- The certificate is valid at the time of signing.
- Revocation — OCSP or CRL. Without this verification, the signature of the dismissed director or the stolen key will be "valid."
- Key assignment via Key Usage / Extended Key Usage certificate: does it allow document signing. Do not accept old AUTH keys for document signing.
- Subject: The signatory's IIN and, for legal entities, the organization's BIN match the expected ones.
- 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 · 0
No comments yet.Sign in to comment, rate and see all comments.