A Python-based web application that allows reading data from Portuguese Citizen Cards (Cartão de Cidadão) using the official Autenticação.gov plugin.
Read more about this project and the technical details in my blog.
- Read basic citizen information from the card
- Extract and convert photo from JP2 to JPEG format
- Secure communication with government authentication plugin
- Support for both local and cloud plugin endpoints
- Python 3.6 or higher
- Card Reader compatible with Portuguese Citizen Card
- Plugin Autenticação.gov installed and running
- Certificate .p12 file and password from Autenticação.gov
- Clone this repository:
git clone https://github.com/tragio/portuguese-citizen-card-web-reader.git
cd portuguese-citizen-card-web-reader
- Install required Python packages:
pip install -r requirements.txt
-
Place your .p12 certificate in the certs directory
-
Update the certificate password in config.py
- Start the FastAPI server:
uvicorn main:app --reload --port 8000
-
Open your browser and go to http://127.0.0.1:8000/
-
Insert your Citizen Card in the reader
-
Click "Run Complete Chain" to read the card data
You need to ask Autenticação.gov entity for the certificate, you will receive a certificate .jks
file. You need to convert this file to a .p12
file. You can use the following command to convert the .jks
file to a .p12
file:
Convert the certificate using this command:
keytool -importkeystore -srckeystore CERTIFICATE_NAME.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore gov_cert.p12
Contributions are welcome! Please feel free to submit a Pull Request.
If you find this project useful and you are in the mood, feel free to offer me a coffee: