pidgin/pidgin

887efbd652d8
certificate: Use public key fingerprint to compare certificates

This fixes an issue with google talk's certificates and gnutls, where the root
certificate in the provided chain is a slightly different version of the one
that is usually present in the certificate stores, but the SubjectPublicKeyInfo
section is the same.

This adds a PurpleCertificateScheme function, compare_pubkeys, and its wrapper
purple_certificate_compare_pubkeys().

This is only implemented for gnutls, since the NSS plugin only uses the NSS
certificate validation code. Even if that path was reachable from a plugin that
doesn't implement this method, it would return FALSE and behave as if this bug
was never fixed.

The gnutls implementation uses the gnutls_x509_crt_get_key_id() function,
which returns a hash of the SubjectPublicKeyInfo section of the certificate.

In gnutls versions older than 3.4.1, this may be a SHA1 hash, but after that
version SHA256 support was added (without much fanfare - the documentation
barely mentions this at all), and we just use the constant for the best known
algo, which for current versions is just SHA256. Older versions ignore that
flag parameter.

The whole comparison is modeled after the private _gnutls_check_if_same_key(),
which checks if both certificates have the same DN ("unique id") and does a
memcmp() of the raw SPKI section. We don't have direct access to the raw SPKI
section but comparing their fingerprints is good enough.
a3d157700972b48cf0a23b300261a5ab0c6e165b v2.10.5
4992bd90d8ad78ebdd324dd90d3e9d443f7dd002 v2.10.6
ad7e7fb98db3bbd7bf9ab49072fd34cd4fa25dd9 v2.10.7
5010e6877abce3bfc2a4912e6b38fed7d6d3df19 v2.10.8
9438f4b2904d9574b9e6ffba463d354b3661139f v2.10.9
b7fedd2a570b760f252cf8a65a584137ab0af2cb v2.10.10
e38a9aa5b1f8d25c58a0a7da05b386f265cba6e3 v2.10.11
2ac1dcb9eb2ef9907ae0894ffad0c0e1b2e10f7d v2.10.12
0b7591cc7360e3fc0f6ff44df7840a286ddcba74 v2.11.0