NEW ANSWER:
Reviewing your link #4, it seems like you've investigated existing utilities and received the answer that what you want would have to be programmed. Doing so is relatively trivial. The following Perl script will do what you want:
#!/usr/bin/perl
# Code snippets taken from Net::SSLeay documentation and mildly modified.
# Requires a newer version of SSLeay (tested with 1.48)
# Needless to say, verify correct $host and $fingerprint before testing!!!
use Net::SSLeay qw(get_https3);
$host = "www.google.com";
$port = 443;
$fingerprint = "C1:95:6D:C8:A7:DF:B2:A5:A5:69:34:DA:09:77:8E:3A:11:02:33:58";
($p, $resp, $hdrs, $server_cert) = get_https3($host, $port, '/');
if (!defined($server_cert) || ($server_cert == 0)) {
warn "Subject Name: undefined, Issuer Name: undefined";
} elsif (Net::SSLeay::X509_get_fingerprint($server_cert, "sha1") ne $fingerprint) {
warn 'Invalid certificate fingerprint '
. Net::SSLeay::X509_get_fingerprint($server_cert, "sha1")
. ' for ' . Net::SSLeay::X509_NAME_oneline(
Net::SSLeay::X509_get_subject_name($server_cert));
} else {
print $p;
}
As is outlined in the Net::SSLeay documentation, this method means verification after the HTTP transaction, and so should not be used if you want to verify you're talking to the right server before sending them data. But if all you're doing is deciding whether or not to trust what you just downloaded (which is sounds like you are from your reference #4) this is fine.
OLD ANSWER:
You can use openssl as described here:
To wit,
openssl s_client -connect <host>:<port> < /dev/null 2>/dev/null | openssl x509 -fingerprint -noout -in /dev/stdin
(Old answer was) Updated
As @Gilles has pointed out, this doesn't meet the requirement to combine the certificate verification with the actual content retrieval.
Because openssl s_client combines the certificate information and the server response into the stdout stream, it cannot be simply used for this purpose. It is probably possible to write a script that would slurp up the combined output and separate the two based on some simple test parsing, but that's not exactly a turnkey solution.