You can retrieve the Common Name (CN) from an SSL certificate using the openssl command line tool. The following command will extract the CN from a certificate file cert.pem:
openssl x509 -noout -subject -in cert.pem | awk -F= '/CN=/ {print $2}'
The x509 option is used to specify the X.509 certificate format, and the -noout option is used to suppress output of the certificate details. The -subject option is used to display the subject field of the certificate, which includes the CN. The awk command is used to extract the value of the CN field.