--- /dev/null
+#pragma once
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/** Attribute definitions for lib curl
+ *
+ * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
+ */
+RCSIDH(attrs_h, "$Id$")
+
+extern fr_dict_attr_t const *attr_tls_cert;
#include <freeradius-devel/util/talloc.h>
+#include "attrs.h"
+
static uint32_t instance_count = 0;
+
+fr_dict_attr_t const *attr_tls_cert;
static fr_dict_t const *dict_freeradius; /*internal dictionary for server*/
+extern fr_dict_attr_autoload_t curl_attr[];
+fr_dict_attr_autoload_t curl_attr[] = {
+ { .out = &attr_tls_cert, .name = "TLS-Cert", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
+ { NULL }
+};
+
static fr_dict_autoload_t curl_dict[] = {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
return -1;
}
+ if (fr_dict_attr_autoload(curl_attr) < 0) {
+ PERROR("Failed loading dictionaries for curl");
+ return -1;
+ }
+
ret = curl_global_init(CURL_GLOBAL_ALL);
if (ret != CURLE_OK) {
ERROR("CURL init returned error: %i - %s", ret, curl_easy_strerror(ret));
CURLcode ret;
int i;
char buffer[265];
- char *p , *q, *attr = buffer;
+ char *p , *q;
fr_pair_list_t cert_vps;
/*
* Examples and documentation show cert_info being
return -1;
}
- attr += strlcpy(attr, "TLS-Cert-", sizeof(buffer));
-
RDEBUG2("Chain has %i certificate(s)", ptr.to_certinfo->num_of_certs);
for (i = 0; i < ptr.to_certinfo->num_of_certs; i++) {
struct curl_slist *cert_attrs;
+ fr_pair_t *container;
+
+ MEM(container = fr_pair_afrom_da(request->request_ctx, attr_tls_cert));
+ fr_pair_append(&cert_vps, container);
RDEBUG2("Processing certificate %i",i);
continue;
}
- strlcpy(attr, cert_attrs->data, (q - cert_attrs->data) + 1);
- for (p = attr; *p != '\0'; p++) if (*p == ' ') *p = '-';
+ strlcpy(buffer, cert_attrs->data, (q - cert_attrs->data) + 1);
+ for (p = buffer; *p != '\0'; p++) if (*p == ' ') *p = '-';
- da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_freeradius), buffer);
+ da = fr_dict_attr_by_name(NULL, attr_tls_cert, buffer);
if (!da) {
RDEBUG3("Skipping %s += '%s'", buffer, q + 1);
RDEBUG3("If this value is required, define attribute \"%s\"", buffer);
continue;
}
- MEM(vp = fr_pair_afrom_da(request->request_ctx, da));
+ MEM(vp = fr_pair_afrom_da(container, da));
fr_pair_value_from_str(vp, q + 1, -1, '\0', true);
- fr_pair_append(&cert_vps, vp);
+ fr_pair_append(&container->vp_group, vp);
}
/*
* Add a copy of the cert_vps to the request list.