Tested on

FreeBSD 11

Zabbix 3.4

script /usr/local/etc/zabbix34/zabbix/externalscripts/sslinfo.sh :

#/bin/sh

expire_date=$(echo QUIT | timeout 3 openssl s_client -host "$NAME" -port "$PORT" -servername "$NAME" -showcerts /dev/null | sed -n '/BEGIN CERTIFICATE/,/END CERT/p' | openssl x509 -text 2>/dev/null | sed -n 's/ *Not After : *//p')

if [ -n "$expire_date" ]; then
expire_date_unix=$(date -j -f "%b %d %T %Y %Z" "$expire_date" '+%s')
else
expire_date_unix=0
fi

date_current=$(date "+%s")
secs_left=$(( $expire_date_unix-$date_current ))
days_left=$(date -j -f "%s" "$secs_left" '+%d' )

echo $days_left

Next go to zabbix, create new item:

name: "SSL cert example.com"

type: external check

key: sslinfo.sh[example.com]