|
|
7a8c6d |
From afe1fc05a5da349c3e24e8c96b1e185e4da53613 Mon Sep 17 00:00:00 2001
|
|
|
7a8c6d |
From: Fraser Tweedale <ftweedal@redhat.com>
|
|
|
7a8c6d |
Date: Thu, 17 Aug 2017 11:38:43 +1000
|
|
|
7a8c6d |
Subject: [PATCH] MS cert template: add D-Bus property and storage
|
|
|
7a8c6d |
|
|
|
7a8c6d |
Add a D-Bus property and storage for a new template attribute, which
|
|
|
7a8c6d |
will hold data to be included in CSRs in the MS V2 certificate
|
|
|
7a8c6d |
template extension.
|
|
|
7a8c6d |
|
|
|
7a8c6d |
The server does not validate the extension data (validation
|
|
|
7a8c6d |
behaviour is implemented in a subsequent commit).
|
|
|
7a8c6d |
|
|
|
7a8c6d |
Part of: https://pagure.io/certmonger/issue/78
|
|
|
7a8c6d |
---
|
|
|
7a8c6d |
doc/api.txt | 2 ++
|
|
|
7a8c6d |
src/store-files.c | 10 ++++++++++
|
|
|
7a8c6d |
src/store-int.h | 1 +
|
|
|
7a8c6d |
src/tdbus.h | 1 +
|
|
|
7a8c6d |
src/tdbush.c | 29 ++++++++++++++++++++++++++++-
|
|
|
7a8c6d |
tests/028-dbus/expected.out | 1 +
|
|
|
7a8c6d |
6 files changed, 43 insertions(+), 1 deletion(-)
|
|
|
7a8c6d |
|
|
|
7a8c6d |
diff --git a/doc/api.txt b/doc/api.txt
|
|
|
7a8c6d |
index 31016be..83cf375 100644
|
|
|
7a8c6d |
--- a/doc/api.txt
|
|
|
7a8c6d |
+++ b/doc/api.txt
|
|
|
7a8c6d |
@@ -56,6 +56,7 @@ o object layout
|
|
|
7a8c6d |
{("template-crldp"),array-of-string (CRL distribution point URIs)}
|
|
|
7a8c6d |
{("template-ns-comment"),string (Netscape comment)}
|
|
|
7a8c6d |
{("template-profile"),string (certificate profile)}
|
|
|
7a8c6d |
+ {("template-ms-certificate-template"),string (MS V2 template specifier; format: <oid>:<major-version>[:<minor-version>] )}
|
|
|
7a8c6d |
{("template-issuer"),string (requested issuer)}
|
|
|
7a8c6d |
{("template-challenge-password"),string (password to add to CSR)}
|
|
|
7a8c6d |
{("template-challenge-password-file"),string (password file)
|
|
|
7a8c6d |
@@ -165,6 +166,7 @@ o object layout
|
|
|
7a8c6d |
{("template-crldp"),array-of-string (CRL distribution point URIs)}
|
|
|
7a8c6d |
{("template-ns-comment"),string (Netscape comment)}
|
|
|
7a8c6d |
{("template-profile"),string (certificate profile)}
|
|
|
7a8c6d |
+ {("template-ms-certificate-template"),string (MS V2 template specifier; format: <oid>:<major-version>[:<minor-version>] )}
|
|
|
7a8c6d |
{("template-issuer"),string (requested issuer)}
|
|
|
7a8c6d |
{("template-challenge-password"),string (password to add to CSR)}
|
|
|
7a8c6d |
{("template-challenge-password-file"),string (password file)
|
|
|
7a8c6d |
diff --git a/src/store-files.c b/src/store-files.c
|
|
|
7a8c6d |
index 889829c..977e896 100644
|
|
|
7a8c6d |
--- a/src/store-files.c
|
|
|
7a8c6d |
+++ b/src/store-files.c
|
|
|
7a8c6d |
@@ -130,6 +130,7 @@ enum cm_store_file_field {
|
|
|
7a8c6d |
cm_store_entry_field_template_ns_comment,
|
|
|
7a8c6d |
cm_store_entry_field_template_profile,
|
|
|
7a8c6d |
cm_store_entry_field_template_issuer,
|
|
|
7a8c6d |
+ cm_store_entry_field_template_certificate_template,
|
|
|
7a8c6d |
cm_store_entry_field_template_no_ocsp_check,
|
|
|
7a8c6d |
cm_store_entry_field_template_ns_certtype,
|
|
|
7a8c6d |
|
|
|
7a8c6d |
@@ -305,6 +306,7 @@ static struct cm_store_file_field_list {
|
|
|
7a8c6d |
{cm_store_entry_field_template_profile, "template_profile"}, /* right */
|
|
|
7a8c6d |
{cm_store_entry_field_template_profile, "ca_profile"}, /* wrong */
|
|
|
7a8c6d |
{cm_store_entry_field_template_issuer, "template_issuer"},
|
|
|
7a8c6d |
+ {cm_store_entry_field_template_certificate_template, "template_certificate_template"},
|
|
|
7a8c6d |
{cm_store_entry_field_template_no_ocsp_check, "template_no_ocsp_check"},
|
|
|
7a8c6d |
{cm_store_entry_field_template_ns_certtype, "template_ns_certtype"},
|
|
|
7a8c6d |
|
|
|
7a8c6d |
@@ -1129,6 +1131,9 @@ cm_store_entry_read(void *parent, const char *filename, FILE *fp)
|
|
|
7a8c6d |
case cm_store_entry_field_template_profile:
|
|
|
7a8c6d |
ret->cm_template_profile = free_if_empty(p);
|
|
|
7a8c6d |
break;
|
|
|
7a8c6d |
+ case cm_store_entry_field_template_certificate_template:
|
|
|
7a8c6d |
+ ret->cm_template_certificate_template = free_if_empty(p);
|
|
|
7a8c6d |
+ break;
|
|
|
7a8c6d |
case cm_store_entry_field_template_issuer:
|
|
|
7a8c6d |
ret->cm_template_issuer = free_if_empty(p);
|
|
|
7a8c6d |
break;
|
|
|
7a8c6d |
@@ -1375,6 +1380,7 @@ cm_store_ca_read(void *parent, const char *filename, FILE *fp)
|
|
|
7a8c6d |
case cm_store_entry_field_template_ocsp_location:
|
|
|
7a8c6d |
case cm_store_entry_field_template_ns_comment:
|
|
|
7a8c6d |
case cm_store_entry_field_template_profile:
|
|
|
7a8c6d |
+ case cm_store_entry_field_template_certificate_template:
|
|
|
7a8c6d |
case cm_store_entry_field_template_issuer:
|
|
|
7a8c6d |
case cm_store_entry_field_template_no_ocsp_check:
|
|
|
7a8c6d |
case cm_store_entry_field_template_ns_certtype:
|
|
|
7a8c6d |
@@ -1984,6 +1990,8 @@ cm_store_entry_write(FILE *fp, struct cm_store_entry *entry)
|
|
|
7a8c6d |
entry->cm_template_no_ocsp_check ? 1 : 0);
|
|
|
7a8c6d |
cm_store_file_write_str(fp, cm_store_entry_field_template_ns_certtype,
|
|
|
7a8c6d |
entry->cm_template_ns_certtype);
|
|
|
7a8c6d |
+ cm_store_file_write_str(fp, cm_store_entry_field_template_certificate_template,
|
|
|
7a8c6d |
+ entry->cm_template_certificate_template);
|
|
|
7a8c6d |
|
|
|
7a8c6d |
cm_store_file_write_str(fp, cm_store_entry_field_challenge_password,
|
|
|
7a8c6d |
entry->cm_template_challenge_password);
|
|
|
7a8c6d |
@@ -2745,6 +2753,8 @@ cm_store_entry_dup(void *parent, struct cm_store_entry *entry)
|
|
|
7a8c6d |
ret->cm_template_profile = cm_store_maybe_strdup(ret, entry->cm_template_profile);
|
|
|
7a8c6d |
ret->cm_template_issuer = cm_store_maybe_strdup(ret, entry->cm_template_issuer);
|
|
|
7a8c6d |
ret->cm_template_no_ocsp_check = entry->cm_template_no_ocsp_check;
|
|
|
7a8c6d |
+ ret->cm_template_certificate_template =
|
|
|
7a8c6d |
+ cm_store_maybe_strdup(ret, entry->cm_template_certificate_template);
|
|
|
7a8c6d |
ret->cm_template_ns_certtype = cm_store_maybe_strdup(ret,
|
|
|
7a8c6d |
entry->cm_template_ns_certtype);
|
|
|
7a8c6d |
|
|
|
7a8c6d |
diff --git a/src/store-int.h b/src/store-int.h
|
|
|
7a8c6d |
index 2d3a353..98b37e6 100644
|
|
|
7a8c6d |
--- a/src/store-int.h
|
|
|
7a8c6d |
+++ b/src/store-int.h
|
|
|
7a8c6d |
@@ -144,6 +144,7 @@ struct cm_store_entry {
|
|
|
7a8c6d |
char *cm_template_profile;
|
|
|
7a8c6d |
char *cm_template_issuer;
|
|
|
7a8c6d |
char *cm_template_ns_certtype;
|
|
|
7a8c6d |
+ char *cm_template_certificate_template;
|
|
|
7a8c6d |
unsigned int cm_template_no_ocsp_check: 1;
|
|
|
7a8c6d |
/* A challenge password, which may be included (in cleartext form!) in
|
|
|
7a8c6d |
* a CSR. */
|
|
|
7a8c6d |
diff --git a/src/tdbus.h b/src/tdbus.h
|
|
|
7a8c6d |
index 496f2dd..7164f11 100644
|
|
|
7a8c6d |
--- a/src/tdbus.h
|
|
|
7a8c6d |
+++ b/src/tdbus.h
|
|
|
7a8c6d |
@@ -110,6 +110,7 @@
|
|
|
7a8c6d |
#define CM_DBUS_PROP_TEMPLATE_PROFILE "template-profile"
|
|
|
7a8c6d |
#define CM_DBUS_PROP_TEMPLATE_ISSUER "template-issuer"
|
|
|
7a8c6d |
#define CM_DBUS_PROP_TEMPLATE_NS_CERTTYPE "template-ns-certtype"
|
|
|
7a8c6d |
+#define CM_DBUS_PROP_TEMPLATE_MS_CERTIFICATE_TEMPLATE "template-ms-certificate-template"
|
|
|
7a8c6d |
#define CM_DBUS_SIGNAL_REQUEST_CERT_SAVED "SavedCertificate"
|
|
|
7a8c6d |
#define CM_DBUS_PROP_CA_PRESAVE_COMMAND "ca-presave-command"
|
|
|
7a8c6d |
#define CM_DBUS_PROP_CA_PRESAVE_UID "ca-presave-uid"
|
|
|
7a8c6d |
diff --git a/src/tdbush.c b/src/tdbush.c
|
|
|
7a8c6d |
index 631da3e..94bf793 100644
|
|
|
7a8c6d |
--- a/src/tdbush.c
|
|
|
7a8c6d |
+++ b/src/tdbush.c
|
|
|
7a8c6d |
@@ -1568,6 +1568,14 @@ base_add_request(DBusConnection *conn, DBusMessage *msg,
|
|
|
7a8c6d |
new_entry->cm_template_issuer = maybe_strdup(new_entry,
|
|
|
7a8c6d |
param->value.s);
|
|
|
7a8c6d |
}
|
|
|
7a8c6d |
+ param = cm_tdbusm_find_dict_entry(d,
|
|
|
7a8c6d |
+ CM_DBUS_PROP_TEMPLATE_MS_CERTIFICATE_TEMPLATE,
|
|
|
7a8c6d |
+ cm_tdbusm_dict_s);
|
|
|
7a8c6d |
+ if (param != NULL) {
|
|
|
7a8c6d |
+ // TODO check validity
|
|
|
7a8c6d |
+ new_entry->cm_template_certificate_template = maybe_strdup(new_entry,
|
|
|
7a8c6d |
+ param->value.s);
|
|
|
7a8c6d |
+ }
|
|
|
7a8c6d |
param = cm_tdbusm_find_dict_entry(d,
|
|
|
7a8c6d |
CM_DBUS_PROP_TEMPLATE_CHALLENGE_PASSWORD,
|
|
|
7a8c6d |
cm_tdbusm_dict_s);
|
|
|
7a8c6d |
@@ -3320,6 +3328,17 @@ request_modify(DBusConnection *conn, DBusMessage *msg,
|
|
|
7a8c6d |
propname[n_propname++] = CM_DBUS_PROP_TEMPLATE_ISSUER;
|
|
|
7a8c6d |
}
|
|
|
7a8c6d |
} else
|
|
|
7a8c6d |
+ if ((param->value_type == cm_tdbusm_dict_s) &&
|
|
|
7a8c6d |
+ (strcasecmp(param->key, CM_DBUS_PROP_TEMPLATE_MS_CERTIFICATE_TEMPLATE) == 0)) {
|
|
|
7a8c6d |
+ talloc_free(entry->cm_template_certificate_template);
|
|
|
7a8c6d |
+ // TODO check validity
|
|
|
7a8c6d |
+ entry->cm_template_certificate_template =
|
|
|
7a8c6d |
+ maybe_strdup(entry, param->value.s);
|
|
|
7a8c6d |
+ if (n_propname + 2 < sizeof(propname) / sizeof(propname[0])) {
|
|
|
7a8c6d |
+ propname[n_propname++] =
|
|
|
7a8c6d |
+ CM_DBUS_PROP_TEMPLATE_MS_CERTIFICATE_TEMPLATE;
|
|
|
7a8c6d |
+ }
|
|
|
7a8c6d |
+ } else
|
|
|
7a8c6d |
if ((param->value_type == cm_tdbusm_dict_s) &&
|
|
|
7a8c6d |
(strcasecmp(param->key, CM_DBUS_PROP_TEMPLATE_CHALLENGE_PASSWORD) == 0)) {
|
|
|
7a8c6d |
talloc_free(entry->cm_template_challenge_password);
|
|
|
7a8c6d |
@@ -6734,6 +6753,14 @@ cm_tdbush_iface_request(void)
|
|
|
7a8c6d |
offsetof(struct cm_store_entry, cm_template_issuer),
|
|
|
7a8c6d |
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
7a8c6d |
NULL),
|
|
|
7a8c6d |
+ make_interface_item(cm_tdbush_interface_property,
|
|
|
7a8c6d |
+ make_property(CM_DBUS_PROP_TEMPLATE_MS_CERTIFICATE_TEMPLATE,
|
|
|
7a8c6d |
+ cm_tdbush_property_string,
|
|
|
7a8c6d |
+ cm_tdbush_property_readwrite,
|
|
|
7a8c6d |
+ cm_tdbush_property_char_p,
|
|
|
7a8c6d |
+ offsetof(struct cm_store_entry, cm_template_certificate_template),
|
|
|
7a8c6d |
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
7a8c6d |
+ NULL),
|
|
|
7a8c6d |
make_interface_item(cm_tdbush_interface_property,
|
|
|
7a8c6d |
make_property(CM_DBUS_PROP_TEMPLATE_NS_CERTTYPE,
|
|
|
7a8c6d |
cm_tdbush_property_string,
|
|
|
7a8c6d |
@@ -7179,7 +7206,7 @@ cm_tdbush_iface_request(void)
|
|
|
7a8c6d |
make_interface_item(cm_tdbush_interface_signal,
|
|
|
7a8c6d |
make_signal(CM_DBUS_SIGNAL_REQUEST_CERT_SAVED,
|
|
|
7a8c6d |
NULL),
|
|
|
7a8c6d |
- NULL))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
|
|
|
7a8c6d |
+ NULL)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
|
|
|
7a8c6d |
}
|
|
|
7a8c6d |
return ret;
|
|
|
7a8c6d |
}
|
|
|
7a8c6d |
diff --git a/tests/028-dbus/expected.out b/tests/028-dbus/expected.out
|
|
|
7a8c6d |
index 93cc4d1..8a81a7f 100644
|
|
|
7a8c6d |
--- a/tests/028-dbus/expected.out
|
|
|
7a8c6d |
+++ b/tests/028-dbus/expected.out
|
|
|
7a8c6d |
@@ -330,6 +330,7 @@ OK
|
|
|
7a8c6d |
<property name="template-ns-comment" type="s" access="readwrite"/>
|
|
|
7a8c6d |
<property name="template-profile" type="s" access="readwrite"/>
|
|
|
7a8c6d |
<property name="template-issuer" type="s" access="readwrite"/>
|
|
|
7a8c6d |
+ <property name="template-ms-certificate-template" type="s" access="readwrite"/>
|
|
|
7a8c6d |
<property name="template-ns-certtype" type="s" access="readwrite"/>
|
|
|
7a8c6d |
<property name="template-challenge-password" type="s" access="readwrite"/>
|
|
|
7a8c6d |
<property name="template-challenge-password-file" type="s" access="readwrite"/>
|
|
|
7a8c6d |
--
|
|
|
7a8c6d |
2.14.4
|
|
|
7a8c6d |
|