Sign inSign up free

1026. Public Key Pins for a Mobile App

medium 20 XP ~11 minHands-on lab

The mobile team pins the server's public key (not the certificate), so certificates can be renewed with the same key. They need the pins, and the release check needs a way to confirm a server presents a pinned key. The files are in /home/student/pki/: server.pem (the live certificate) and backup.key (a backup key kept offline, for emergencies).

Task

  1. Write /home/student/pki/pins.txt with two lines, the pin of server.pem's key first, then the backup key's:

    pin-sha256="<base64 of the SHA-256 of the DER SubjectPublicKeyInfo>"
    
  2. Create the executable script /home/student/bin/check-pin.sh HOST PORT that connects with TLS (sending HOST as SNI), computes the pin of the certificate the server presents, and exits 0 if it is in pins.txt, 1 if not.

Test servers: run /srv/lab/bin/start-pin-servers; ports 9551, 9552 and 9553 on 127.0.0.1.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Networking and TLS in Practice. Next step: Verify Webhook Signatures

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.