>_ IzzyLab

Topic breakdown

The openssl s_client client is a TLS diagnostic tool: it establishes a connection, performs the handshake and lays out everything about it, including the PEM certificate the server presents. The subtlety is that the client is interactive and after the handshake waits for input from stdin, so the input needs to be closed and the chatter on stderr muted. Then you parse the obtained certificate with the certificate command openssl x509, pull the CN value from the subject with text processing and store it in a file — essentially you learn to build a pipeline connection → cert parsing → field extraction.

What's checked

  1. nginx on 8443 serves a certificate
  2. cn.txt has the CN of the certificate the server presents

What it looks like