diff options
author | José Bollo <jose.bollo@iot.bzh> | 2015-12-03 15:30:21 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2015-12-03 15:30:21 +0100 |
commit | 82a1641c0570e6548649dac932853959854cd706 (patch) | |
tree | 18437659a193dec4a14ae5b40b8e0b74a28385d5 | |
parent | 3c72eb90658c072d50b18c48f2d8857bbc546b42 (diff) |
allows concatenation of multiple certificates
Change-Id: If7352761b49e1ba5ff76800fa4fb093b8cb878f2
-rw-r--r-- | wgtpkg-certs.c | 24 |
1 files 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) |