How to verify SSL SHA-1 Certificate Fingerprnit Signature of your mail/web server to avoid hijacking/man-in-the-middle attacks

This is especially helpful if you run your own servers.  If you are presented with an error message or warning that the signature has changed or does not match the IP/domain you are connecting to you always want to verify manually.

So your e-mail/web client will show you an SHA-1 fingerprint like this:

"Could not verify this certificate because the issuer is unkown" or other reasons such as a mismatch in IP/domain.

It will also show you the "SHA1 fingerprint".   Copy this and compare below with the results of your actual server certificate.

How to verify it against the actual certificate on your server?:

openssl x509 -fingerprint -in /pathto/your-certificate.crt -noout

SHA1 Fingerprint=CD:32:57:8A:66:18:71:87:81:B8:A5:F6:2E:52:3D:15:C5:A9:41:06

How to manually fetch the SHA1 certificate straight from the server to compare?

openssl s_client -showcerts -connect yourdomain.com:port 2>/dev/null|openssl x509 -fingerprint -noout

Automated Bash Script

#!/bin/bash

#change servercertpath to your certificate

servercertpath=/etc/ssl/key.crt

#remote host

#change remote host/ip and port number as necessary

remotehost="realtechtalk.com:443"

localfingerprint=`openssl x509 -fingerprint -in $servercertpath -noout`

#the echo -e \n prints a newline to the SSL client this is necessary or it will never exit so the script will halt and not complete

remotefingerprint=`echo -e "\n"|openssl s_client -showcerts -connect $remotehost 2>/dev/null|openssl x509 -fingerprint -noout`

if [ "$localfingerprint" == "$remotefingerprint" ]; then

echo "OK - Certs match: local=$localfingerprint remote=$remotefingerprint"

else

echo "BAD - Certs don't match could be man in the middle!: local=$localfingerprint remote=$remotefingerprint"

fi

 

Conclusion

This is an important and good way to verify that you are actually talking to who you think you are and that there is no direct interception or Middleman attack.


Tags:

verify, ssl, sha, certificate, fingerprnit, server, hijacking, attacksthis, servers, presented, ip, domain, connecting, manually, fingerprint, quot, issuer, unkown, mismatch, openssl, pathto, crt, noout, fetch, s_client, showcerts, yourdomain, dev, null, automated, bash, bin, servercertpath, etc, remotehost, realtechtalk, localfingerprint, echo, newline, halt, remotefingerprint, ok, certs, fi, interception, middleman,

Latest Articles

  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution