GTlsCertificate: fix loading of chain with private key

If a private key (or anything, in fact) follows the final certificate in
the file, certificate parsing will be aborted and only the first
certificate in the chain will be returned, with the private key not set.
Be tolerant of this, rather than expecting the final character in the
file to be the newline following the last certificate.

https://bugzilla.gnome.org/show_bug.cgi?id=754264
This commit is contained in:
Michael Catanzaro 2015-08-28 19:43:09 -05:00
parent 1ab3e3ed3e
commit 587068c969

View File

@ -335,13 +335,19 @@ parse_and_create_certificate_list (const gchar *data,
while (p && *p)
{
gchar *cert_pem;
GError *error = NULL;
cert_pem = parse_next_pem_certificate (&p, end, FALSE, NULL);
if (!cert_pem)
cert_pem = parse_next_pem_certificate (&p, end, FALSE, &error);
if (error)
{
g_slist_free_full (pem_list, g_free);
g_error_free (error);
return first_pem_list;
}
else if (!cert_pem)
{
break;
}
pem_list = g_slist_prepend (pem_list, cert_pem);
}