From 82a1641c0570e6548649dac932853959854cd706 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 3 Dec 2015 15:30:21 +0100 Subject: [PATCH] allows concatenation of multiple certificates Change-Id: If7352761b49e1ba5ff76800fa4fb093b8cb878f2 --- wgtpkg-certs.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/wgtpkg-certs.c b/wgtpkg-certs.c index c103c51..1d8b976 100644 --- a/wgtpkg-certs.c +++ b/wgtpkg-certs.c @@ -42,16 +42,22 @@ static int add_certificate_x509(X509 *x) static int add_certificate_bin(const char *bin, int len) { int rc; - const unsigned char *b = (const unsigned char *)bin; - X509 *x = d2i_X509(NULL, &b, len); - if (x == NULL) { - syslog(LOG_ERR, "d2i_X509 failed"); - return -1; + const char *b, *e; + b = bin; + e = bin + len; + while (len) { + X509 *x = d2i_X509(NULL, (const unsigned char **)&b, e-b); + if (x == NULL) { + syslog(LOG_ERR, "d2i_X509 failed"); + return -1; + } + rc = add_certificate_x509(x); + if (rc) { + X509_free(x); + return rc; + } } - rc = add_certificate_x509(x); - if (rc) - X509_free(x); - return rc; + return 0; } int add_certificate_b64(const char *b64) -- 2.16.6