Skip to content

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.

Notifications You must be signed in to change notification settings

Tragio/portuguese-citizen-card-web-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portuguese Citizen Card Web Reader

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.

Features

  • 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

Requirements

  • 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

Installation

  1. Clone this repository:
git clone https://github.com/tragio/portuguese-citizen-card-web-reader.git
cd portuguese-citizen-card-web-reader
  1. Install required Python packages:
pip install -r requirements.txt
  1. Place your .p12 certificate in the certs directory

  2. Update the certificate password in config.py

Usage

  1. Start the FastAPI server:
uvicorn main:app --reload --port 8000
  1. Open your browser and go to http://127.0.0.1:8000/

  2. Insert your Citizen Card in the reader

  3. Click "Run Complete Chain" to read the card data

Certificate

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

Contributing

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:

Buy Me A Coffee

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published