I do not think that you can do this with any of these libraries or even with more advanced libcurl and shells. But alternatively - if you have an openssl command-line tool, you can call it and analyze the output, the command you need is as follows:
openssl s_client -connect my.server.name:443
This will give you a complete dump of the certificate, as well as some analyzed information - the subject, issuer, etc.
source share