kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 445163f7c593b680ddb0b27545e2e465a868b4f6
parent ff40f046939278ef277ddcb24ebf8a318a9f2584
Author: Joris Vink <joris@coders.se>
Date:   Mon, 13 Jan 2020 11:00:40 +0100

Add support for setting an email for ACME.

Can be configured via the acme_email configuration option.

eg:

	acme_email john@example.com

Diffstat:
include/kore/acme.h | 1+
src/acme.c | 14+++++++++++++-
src/config.c | 11+++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/kore/acme.h b/include/kore/acme.h @@ -52,6 +52,7 @@ void kore_acme_get_paths(const char *, char **, char **); int kore_acme_tls_alpn(SSL *, const unsigned char **, unsigned char *, const unsigned char *, unsigned int, void *); +extern char *acme_email; extern char *acme_provider; #if defined(__cplusplus) diff --git a/src/acme.c b/src/acme.c @@ -244,6 +244,7 @@ static char *account_url = NULL; static u_int8_t acme_alpn_name[] = { 0xa, 'a', 'c', 'm', 'e', '-', 't', 'l', 's', '/', '1' }; +char *acme_email = NULL; char *acme_provider = NULL; char *acme_root_path = NULL; char *acme_runas_user = NULL; @@ -505,7 +506,9 @@ acme_account_resolve(struct kore_msg *msg, const void *data) static void acme_account_reg(int resolve_only) { - struct kore_json_item *json; + int len; + char mail[1024]; + struct kore_json_item *json, *contact; if (account_url == NULL) return; @@ -519,6 +522,15 @@ acme_account_reg(int resolve_only) json = kore_json_create_object(NULL, NULL); kore_json_create_literal(json, "termsOfServiceAgreed", KORE_JSON_TRUE); + if (acme_email) { + len = snprintf(mail, sizeof(mail), "mailto:%s", acme_email); + if (len == -1 || (size_t)len >= sizeof(mail)) + fatalx("mail contact '%s' too large", acme_email); + + contact = kore_json_create_array(json, "contact"); + kore_json_create_string(contact, NULL, mail); + } + if (resolve_only) { kore_json_create_literal(json, "onlyReturnExisting", KORE_JSON_TRUE); diff --git a/src/config.c b/src/config.c @@ -70,6 +70,7 @@ static int configure_file(char *); static int configure_acme(char *); static int configure_acme_root(char *); static int configure_acme_runas(char *); +static int configure_acme_email(char *); static int configure_acme_provider(char *); #endif @@ -228,6 +229,7 @@ static struct { #if defined(KORE_USE_ACME) { "acme_runas", configure_acme_runas }, { "acme_root", configure_acme_root }, + { "acme_email", configure_acme_email }, { "acme_provider", configure_acme_provider }, #endif #if defined(KORE_USE_PLATFORM_PLEDGE) @@ -636,6 +638,15 @@ configure_acme_root(char *root) } static int +configure_acme_email(char *email) +{ + kore_free(acme_email); + acme_email = kore_strdup(email); + + return (KORE_RESULT_OK); +} + +static int configure_acme_provider(char *provider) { kore_free(acme_provider);