获取过期的SSL证书信息

Now I know its possible to obtain the SSL certificate information with stream_socket_client and openssl_x509_parse

But I was wondering if it's also possible to obtain information about a expired certificate

as seen at https://wrong.host.badssl.com/ for example there is still a certificate present, its just giving an error.

i would like to obtain this error.

1) Expired certificate image

enter image description here

2) Wrong host certificate image

enter image description here