In Bash I'd just:
$ openssl s_client -connect www.example.com:443 </dev/null 2>/dev/null | grep 'subject'
But I want to do it elegantly in ruby.
Thanks,
In Bash I'd just:
$ openssl s_client -connect www.example.com:443 </dev/null 2>/dev/null | grep 'subject'
But I want to do it elegantly in ruby.
Thanks,
You can accomplish what you are trying to do with the built-in OpenSSL Ruby module.
Specifically you can use the SSLSocket class to retrieve the certificate as a X509:Certificate object, which has an accessor for subject.
The example code found here is very close to what you are trying to do.