Replaced custom X509 ASN1_UTCTIME_tostr function with OpenSSL function ASN1_TIME_print.
Added catch errors returned from get certificate functions.