Minor refactoring of key check for reuse

parent 258a6080
...@@ -292,19 +292,29 @@ pubkey_pem(VRT_CTX, VCL_STRING pem) ...@@ -292,19 +292,29 @@ pubkey_pem(VRT_CTX, VCL_STRING pem)
return (NULL); return (NULL);
} }
VCL_VOID static struct VPFX(crypto_key) *
vmod_key_pem_pubkey(VRT_CTX, struct VPFX(crypto_key) *k, crypto_key_ok(VRT_CTX, VCL_STRING name, struct VPFX(crypto_key) *k)
VCL_STRING pem)
{ {
if (! key_ctx_ok(ctx)) if (! key_ctx_ok(ctx))
return; return (NULL);
CHECK_OBJ_NOTNULL(k, VMOD_CRYPTO_KEY_MAGIC); CHECK_OBJ_NOTNULL(k, VMOD_CRYPTO_KEY_MAGIC);
if (k->pkey != NULL) { if (k->pkey != NULL) {
VRT_fail(ctx, "xkey.pem_pubkey(): key already defined"); VRT_fail(ctx, "xkey.%s(): key already defined", name);
return; return (NULL);
} }
return (k);
}
VCL_VOID
vmod_key_pem_pubkey(VRT_CTX, struct VPFX(crypto_key) *k,
VCL_STRING pem)
{
k = crypto_key_ok(ctx, "pem_pubkey", k);
if (k == NULL)
return;
k->pkey = pubkey_pem(ctx, pem); k->pkey = pubkey_pem(ctx, pem);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment