Get the certificate expiration date of an application using codesign on mac?

The selected answer did not quite work for me, but a slight variation found here using openssl did the trick. In short,

codesign -dvvvv --extract-certificates /Applications/Example.app

openssl x509 -inform DER -in codesign0 -text

Use codesign to extract the certificates to the current directory:

codesign --display --extract-certificates /Applications/Example.app

You can then use Quick Look to view them:

qlmanage -c public.x509-certificate -p codesign*