Enable smart cards in snapped browsers

Key Value
Summary Enable smart card authentication in Firefox or Chromium installed from snap.
Categories desktop, packaging
Difficulty 2
Author Marek Suchánek marek.suchanek@canonical.com, Nathan Teodosio nathan.teodosio@canonical.com

Overview

Duration: 2:00

With this configuration, you can use smart card authentication in Firefox or Chromium installed from snap. By default, smart cards do not work in snapped web browsers due to strict confinement in the snap.

What you’ll need

Firefox

Duration: 3:00

Enable smart card access in the Firefox snap. You can choose the graphical or terminal interface:

  • In the GNOME graphical interface:

    1. Open Settings.
    2. Go to Apps → Firefox.
    3. Enable pcscd.
  • In the terminal, enter the following command:

    sudo snap connect firefox:pcscd
    

Load the PKCS#11 smart card module in Firefox:

  1. Open Firefox and go to Settings → Privacy & Security → Security → Security devices.

  2. Click the Load button.

  3. Enter the following line into the Module filename field:

    /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
    

    :warning: Warning
    Do not use the Browse button.

  4. Click OK to confirm.

Chromium

Duration: 3:00

Enable smart card access in the Chromium snap. You can choose the graphical or terminal interface:

  • In the GNOME graphical interface:

    1. Open Settings.
    2. Go to Apps → Chromium Web Browser.
    3. Enable pcscd.
  • In the terminal, enter the following command:

    sudo snap connect chromium:pcscd
    

Load the PKCS#11 smart card module in Chromium:

  1. Install the modutil tool:

    sudo apt install libnss3-tools
    
  2. Add the PKCS#11 smart card module to the NSS Database:

    modutil -dbdir sql:.pki/nssdb/ -add "OpenSC" -libfile /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
    

Test if the authentication works

Duration: 2:00

Open your web browser and try authenticating with your smart card.

Did it work? If not:

Report any bugs

Additional resources

This tutorial connects the pcscd smart card plug to the web browser snap. For details about pcscd, see The pcscd interface.

Please mention Comment #95 : Bug #1967632 : Bugs : firefox package : Ubuntu or add a note to this guide, since 99% of libraries provided by smart-card makers should just work by being inside the snap environment.

Ideally we should provide a tool to easily import them (using the portal + some code that adds them to firefox or chrome through nss)