Can You Use the Portuguese Citizen Card to Authenticate Users in Your Own Application?

Avatar
Author

Every few months someone asks us the same question: can we authenticate users with the Portuguese Citizen Card inside our own application? The answer is yes, and the path is more open than most teams expect. The official middleware is published as open source by AMA, covering the Cartão de Cidadão, Chave Móvel Digital and the professional attribute certification system.

What catches teams out is not the cryptography. It is the reader layer, the choice between authentication and qualified signature, the certificate chain, and what happens when the card in front of you is a version your code has never seen.

The relevant date is June 2024. That is when Portugal began issuing the Cartão de Cidadão v2, redesigned for the security and format standards of Regulation (EU) 2019/1157, which had been in application since 2 August 2021 and was replaced by Regulation (EU) 2025/1208 on 9 July 2025. The v2 card uses ECDSA keys where v1 used RSA, and it supports contactless reading. Version 3.12.0 of the middleware was the first to support it. If your integration predates mid-2024 and nobody has touched it since, it is running against assumptions the card no longer satisfies.

The barrier to using the Citizen Card in a commercial product is engineering effort, not permission.

Is the middleware open to private applications, or only to the state?

Open to anyone. The source, the SDK and the technical documentation are all public. There is no licensing negotiation and no approval gate for reading identity attributes or performing an authentication.

What is gated is different. Issuing credentials is a state function. Acting as a qualified trust service provider requires supervision, and Autenticação.gov is the state service behind it. Using professional attributes involves the authorities that issue them. Reading the card and verifying a signature does not.

Three integration paths, and when each one fits
PKCS#11
Cross-platform token API. The pteid-pkcs11 module ships with the middleware. Best for Java and anything already speaking PKCS#11
Native OS crypto
Windows cryptographic support, CryptoTokenKit via PteidToken on macOS. Best for desktop applications
SDK
C, C++, Java and C#, plus a .NET 8/9 module from 3.13.0. Required for contactless on v2
Most commercial projects use two of the three: the SDK for reading data, PKCS#11 for signing. Contactless reading on v2 requires the newer SDK methods specifically, so a PKCS#11-only design cannot reach that functionality.

What is the difference between authentication and qualified signature?

The card carries two separate certificates with two separate PINs and two very different legal effects. Choosing the wrong one is the most expensive mistake available at the start of a project, because it changes your architecture, your retention obligations and your scope.

For completeness: the card has three PINs, authentication, signature and address, plus a longer cancellation code used to disable the digital functions if the card is lost or stolen. All of them arrive in the PIN letter sent to the citizen.

Authentication
This person is present, now
Uses the authentication PIN. An identity assertion, strong but not a signature. You keep a record that verification happened. Typical use: login, onboarding, age or residency checks.
Qualified signature
This person agreed to this document
Uses the signature PIN. Equivalent legal effect to a handwritten signature under Article 25(2) of Regulation (EU) 910/2014. You keep the signed document plus the data needed to verify it years later.
The trap is scope creep in the wrong direction. A project scoped as login discovers three months in that the business wants signed mandates. Qualified signature brings long-term validation, timestamping, an archive format decision and a retention policy. Decide this in week one.

Why does the card reader break more projects than the cryptography?

Because the cryptography is standardised and the reader layer is not. A browser cannot talk to a smart card on its own. The middleware has to be installed on the user machine, and everything about that is outside your control.

The middleware is not installed. Your application has no reliable way to detect this from a web page, so the failure surfaces as an unexplained error. You need a detection strategy and an install path a non-technical user can follow.
Reader drivers differ by platform and model. The user manual publishes reader compatibility tests across both card versions. What works on a developer laptop with one reader fails on a customer machine with another.
pcsc-lite version conflicts on Linux. On distributions shipping pcsc-lite 2.3.0, such as Ubuntu 24.10 and Fedora 41, a specific flatpak package is required.
The card is removed mid-operation. Common, and your error handling has to distinguish it from a genuine failure.
The PIN is unknown or already blocked. Three wrong attempts block that specific code. The other codes keep working, so an authentication PIN block does not prevent signing, but unblocking requires an in-person visit to an IRN counter with the card and the PIN letter. Your support process needs an answer for this before launch.

Contactless changes this, partly. The v2 card supports contactless reading, which removes the reader from the equation for mobile scenarios. It introduces the CAN, a six-digit number printed on the card, required for contactless operations and distinct from the three PINs. When calling C_Login through PKCS#11 in contactless mode with a v2 card, the CAN is passed as the PIN parameter.

Integrating the Citizen Card and not sure which of the three paths fits your stack?
Talk to our team

What changes between Cartão de Cidadão v1 and v2 for your code?

Enough that code written only against v1 will not behave correctly against v2. And the middleware provides no direct way to ask which version is in the reader.

v1
RSA keys, contact only
The original version. Contact interface, RSA keys and certificates, intermediate CAs available as expected through PKCS#11.
v2, from June 2024
ECDSA, contactless, CAN
ECDSA keys. Contactless over ISO/IEC 14443. Contact mode works after updating the software with no significant integration change. Contactless requires the newer SDK methods. Intermediate CAs may not be returned through PKCS#11.
Two consequences. If any part of your stack assumes RSA it will fail on v2 in a way that looks like a bad card. And the official documentation is explicit that no dedicated PKCS#11 API exists to check the card type or contactless mode, so developers must implement their own strategy. One documented approach: attempt initialisation without a PIN or CAN, and retry with the CAN if that fails. We cover the migration in detail in Citizen Card v1 and v2.

What does each scope actually add to the build?

The variable that drives effort is not the cryptography, which is fixed. It is how many of the following you need, and each one brings its own dependencies and failure modes.

Authentication. Reader detection, middleware presence check, PIN handling, certificate chain and revocation validation, a record of the verification. Effort driven by the number of operating systems and whether an existing login system has to keep working alongside it.
Identity attribute reading. SDK integration, field mapping, a data minimisation decision on what you keep. Effort driven by whether the address PIN is needed, which is a separate PIN and a separate user prompt.
Qualified signature. Document handling, trusted timestamping, long-term validation material, archive format decision, retention policy. Driven by whether signatures must stay verifiable after the certificate expires, which most regulated use cases require.
Contactless on v2. The newer SDK methods, CAN capture in the interface, and a version and mode detection strategy you implement yourself.
Ongoing maintenance. Tracking middleware releases, testing against new card generations, distribution-level dependency changes. The release cadence is not yours to control, and June 2024 broke assumptions in integrations built earlier.

We are not publishing price ranges here, because the honest answer depends on which of these apply, how many platforms you support and what your audit requirements are. Send us the scope and we will give you a number rather than a range.

What do you have to keep, and for how long?

For authentication, you are proving that a verification took place: the fact of it, when, which certificate, and the result of the chain and revocation checks. Not a copy of everything on the card. Under data minimisation, storing the full identity dataset because it was available is a liability rather than a record.

For qualified signature, you are proving something harder: that the signature was valid at the moment it was made, verifiable years later, after the certificate has expired. That requires the signed document, a trusted timestamp, and the validation material captured at signing time.

Two decisions to make explicitly. Do you store the citizen number or a derived identifier, since a pseudonymous internal identifier covers most use cases and reduces exposure considerably. And do you re-verify on every session or trust a session token after the first check, an answer that depends on the risk of the operation and should be written down rather than inherited from whatever the developer chose.

How does this relate to the EUDI Wallet arriving in December 2026?

Every EU member state must make a European Digital Identity Wallet available by 24 December 2026, with obligated private-sector organisations required to accept it roughly a year later. That does not make the Citizen Card obsolete, and the two are not alternatives in the short term. The practical position for the next two to three years is that both will be presented.

Which argues for one architectural decision now. Keep your verification logic behind an interface that does not know which mechanism produced the result. If your application code asks whether this person was verified and to what level, rather than what the card returned, adding wallet acceptance later is an implementation and not a rewrite. Our guides on eIDAS 2.0 implementation and relying party integration cover that side.

Related reading

Citizen Card v1 and v2: what changed for developers The migration list if your integration predates June 2024. ECDSA, PACE, the CAN, and certificate chain building.
eIDAS 2.0 implementation guide What organisations have to decide, build and register before December 2026, from a team maintaining national eID middleware since 2011.
EUDI Wallet relying party integration guide The engineering side of wallet acceptance, and how it differs from card-based verification.
eID Box Our middleware product for organisations adding national eID to their own applications.
Open source or proprietary: which is more secure? Why maintenance cadence matters more than licensing when the code sits under an identity flow.

Frequently asked questions

Access and licensing

Is the Portuguese Citizen Card middleware free to use commercially?
Yes. The middleware is published as open source by AMA in the amagovpt/autenticacao.gov repository, with SDKs for C, C++, Java and C#. No licence negotiation or state approval is required to read the card or verify an authentication in a private application. Issuing credentials and acting as a qualified trust service provider remain regulated activities.
Can a web application read the Citizen Card directly?
Not on its own. A browser cannot communicate with a smart card, so the middleware must be installed on the user device and your application interacts with it locally. This is why a Citizen Card integration always includes a client-side component and a plan for detecting whether the middleware is present.

The new card

What is the CAN and when do you need it?
The CAN is a six-digit Card Access Number printed on the Cartão de Cidadão v2. It is required only for contactless reading and is distinct from the authentication, signature and address PINs. When using C_Login through PKCS#11 in contactless mode with a v2 card, the CAN is supplied as the PIN parameter.
Will code written for the old Citizen Card work with the new one?
For contact-mode operations, updating the middleware is generally sufficient without significant integration changes. Contactless requires new SDK methods. Anything in your stack that assumes RSA will need attention, because v2 uses ECDSA, and intermediate CAs may not be returned through PKCS#11 on v2.

Deployment and what comes next

What has to be installed on the user device?
The Autenticação.gov middleware, which provides the PKCS#11 module and the operating system cryptographic support. A browser cannot reach a smart card without it. Your application therefore needs a way to detect whether it is present and an install path a non-technical user can follow, plus the pcsc-lite flatpak package on Linux distributions shipping pcsc-lite 2.3.0.
Does the EUDI Wallet replace the Citizen Card?
Not in the near term. Member states must make a wallet available by 24 December 2026 and obligated sectors must accept it roughly a year later, but citizen adoption is voluntary and the card retains the widest installed base in Portugal. Expect to support both, which is an argument for keeping verification logic behind a common interface. Our work on digital identity for an archipelago shows what that abstraction buys when the deployment context is unusual.
Caixa Mágica Software
Caixa Mágica Team
Caixa Mágica Software is a Portuguese software company with 20+ years of experience delivering custom software, AI solutions and nearshore development teams for European businesses. We have worked on Portuguese national eID middleware for over a decade.
eID Box · Caixa Mágica Software
Talk to the team that maintains this middleware
We have worked on Portuguese national eID middleware for over a decade. Send us the platforms you need to support and the operations you need to perform, and we will tell you which integration path fits and where your timeline is likely to slip.