From 0ba7ac540827b4813e5703f4ca98857095518ebd Mon Sep 17 00:00:00 2001 From: benjamsf Date: Mon, 23 Nov 2026 13:00:16 +0200 Subject: [PATCH 1/2] fix: the certificate subject is the callsign alone Deploy App refuses a request whose subject holds anything more, so the host id no longer follows as OU. --- README.rst | 14 ++++++-------- src/odmdm_connector/template.json | 7 +++---- src/odmdm_connector/template.py | 13 +++++++------ tests/test_template.py | 9 ++++----- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.rst b/README.rst index 32f8999..9855727 100644 --- a/README.rst +++ b/README.rst @@ -39,7 +39,7 @@ An MDM fits, for managed Android phones, if an operator can do five things in it 2. Send each phone's certificate request to Deploy App's SCEP URL with one challenge, the same for every phone of an enrolment window. 3. Put a value that can be set for each phone into the certificate subject: the callsign, as the - common name. + common name, and nothing else. 4. Take a new challenge for each enrolment window. 5. Ask one phone for its certificate again and leave the others alone. @@ -555,17 +555,15 @@ a deployment installs, and give your copy as the template. The certificate subject is the contract with the deployment. Its common name becomes the callsign: 3 to 32 letters, digits or hyphens, no hyphen at either end. It is the name ``name`` gives the -phone, optionally followed by Fleet's id for the host:: +phone, and the subject holds nothing else:: - CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART The tool refuses any other subject; it takes ``$FLEET_VAR_HOST_END_USER_IDP_USERNAME`` in place of -the ``_LOCAL_PART`` form, which is the same text for a callsign. The shipped template uses the -first: the id travels in the certificate request, so the deployment can tell later which device a -callsign was issued to. A subject cannot change on a team that has phones, since replacing the -certificate template removes every phone's certificate, so a team set up without the id keeps the -second form in a template of its own. +the ``_LOCAL_PART`` form, which is the same text for a callsign. Deploy App refuses a request +whose subject holds more than the callsign. Version 1.5 put Fleet's id for the host after it, as +``OU``: a team set up that way needs a new team, because a subject cannot change on a team that +has phones, since replacing the certificate template removes every phone's certificate. A name the phone supplies, such as its serial number, would make a leaked enrolment link enough for an identity. diff --git a/src/odmdm_connector/template.json b/src/odmdm_connector/template.json index 10ce4b2..e771999 100644 --- a/src/odmdm_connector/template.json +++ b/src/odmdm_connector/template.json @@ -41,9 +41,8 @@ "The template Fleet fills in per phone. Its common name becomes the phone's callsign: 3-32", "letters, digits or inner hyphens. This is the name `odmdm-connector name` gives a phone, and", "the connector refuses any other common name: one the phone supplies, such as its serial", - "number, would make a leaked enrolment link enough for an identity. Fleet's id for the phone", - "follows it as OU, so the deployment can tell later which device a callsign was issued to;", - "leave the OU out only for a team that already has phones under a subject without it.", + "number, would make a leaked enrolment link enough for an identity. The subject is that name", + "and nothing else: the deployment refuses a request whose subject holds anything more.", "The name becomes the Android keystore alias, so it is per deployment.", "No certificate authority is named: the connector finds this Deploy App's in the MDM by the", "address it serves, and makes one when there is none, called ODMDM_ and the first part of the", @@ -51,7 +50,7 @@ "So one MDM can serve several Deploy Apps. \"authority\": \"NAME\" here gives a new one that name." ], "name": "{key_alias}", - "subject": "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID" + "subject": "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART" }, "link_app": { "_comment": "A launcher icon so nobody has to know where the server lives. It is a browser shortcut, so it only works alongside the browser and the certificate.", diff --git a/src/odmdm_connector/template.py b/src/odmdm_connector/template.py index a2151f1..65c0a73 100644 --- a/src/odmdm_connector/template.py +++ b/src/odmdm_connector/template.py @@ -33,10 +33,11 @@ class TemplateError(ValueError): """The document is not something we can act on""" -#: The callsign as the common name, from the name the operator gives the phone, and optionally the -#: MDM's own device id beside it. Anything the phone or the enrolment link supplies, a serial -#: number for one, would let whoever holds a leaked enrolment link pick an identity. -SUBJECT = re.compile(r"CN=\$FLEET_VAR_HOST_END_USER_IDP_USERNAME(_LOCAL_PART)?(\s*,\s*OU=\$FLEET_VAR_HOST_UUID)?") +#: The callsign as the common name, from the name the operator gives the phone, and nothing else: +#: the deployment refuses a request whose subject holds more. Anything the phone or the enrolment +#: link supplies, a serial number for one, would let whoever holds a leaked enrolment link pick +#: an identity. +SUBJECT = re.compile(r"CN=\$FLEET_VAR_HOST_END_USER_IDP_USERNAME(_LOCAL_PART)?") def _unsafe(policy: dict[str, Any], certificate: dict[str, Any] | None) -> str: @@ -46,8 +47,8 @@ def _unsafe(policy: dict[str, Any], certificate: dict[str, Any] | None) -> str: """ if certificate is not None and not SUBJECT.fullmatch(str(certificate.get("subject", ""))): return ( - "the certificate subject must be CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, optionally " - "followed by OU=$FLEET_VAR_HOST_UUID, so the callsign is the name the operator gave the phone" + "the certificate subject must be CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART and nothing " + "else, so the callsign is the name the operator gave the phone and the deployment takes the request" ) rules = policy.get("choosePrivateKeyRules", []) if not isinstance(rules, list): diff --git a/tests/test_template.py b/tests/test_template.py index db22e0e..f2be611 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -81,8 +81,6 @@ def _with(policy: dict[str, object] | None = None, subject: str = NAMED) -> dict [ NAMED, "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME", - "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID", - "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME,OU=$FLEET_VAR_HOST_UUID", ], ) def test_the_callsign_is_the_name_the_operator_gave(tmp_path: Path, subject: str) -> None: @@ -96,6 +94,7 @@ def test_the_callsign_is_the_name_the_operator_gave(tmp_path: Path, subject: str (_with(subject="CN=$FLEET_VAR_HOST_HARDWARE_SERIAL"), "certificate subject must be CN="), (_with(subject="CN=OTTER1"), "certificate subject must be CN="), (_with(subject=NAMED + ", OU=$FLEET_VAR_HOST_HARDWARE_SERIAL"), "certificate subject must be CN="), + (_with(subject=NAMED + ", OU=$FLEET_VAR_HOST_UUID"), "certificate subject must be CN="), (_with(subject="OU=$FLEET_VAR_HOST_UUID, " + NAMED), "certificate subject must be CN="), ( _with({"choosePrivateKeyRules": [{"urlPattern": "x", "privateKeyAlias": "rmscep"}]}), @@ -194,9 +193,9 @@ def test_a_template_may_name_its_authority(tmp_path: Path) -> None: assert template.certificate is not None and template.certificate.authority == "RMSCEP" -def test_the_shipped_subject_carries_the_device_id() -> None: - """A subject cannot change once a team has phones, so the id is there from the first template""" +def test_the_shipped_subject_is_the_callsign_alone() -> None: + """The deployment refuses a request whose subject holds more than the callsign""" template = load(EXAMPLE, domain="example.fi", key_alias="rmscep") assert template.certificate is not None - assert template.certificate.subject == f"{NAMED}, OU=$FLEET_VAR_HOST_UUID" + assert template.certificate.subject == NAMED From 9064d9ecf7dbbecaa2752c36b2c279a06ce7edf3 Mon Sep 17 00:00:00 2001 From: benjamsf Date: Mon, 23 Nov 2026 13:00:37 +0200 Subject: [PATCH 2/2] chore: bump version to 1.6.0+261123 --- .bumpversion.toml | 2 +- pyproject.toml | 2 +- src/odmdm_connector/__init__.py | 2 +- tests/test_odmdm_connector.py | 2 +- uv.lock | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 7498d30..7aeae93 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "1.5.0+261122" +current_version = "1.6.0+261123" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)\\+(?P\\d+)" serialize = ["{major}.{minor}.{patch}+{build}"] search = "{current_version}" diff --git a/pyproject.toml b/pyproject.toml index 80e72e5..5659425 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "odmdm-connector" -version = "1.5.0+261122" +version = "1.6.0+261123" description = "Connects an MDM, FleetDM built in, to an OpenDefence deployment's SCEP device enrolment" authors = [ { name = "Benjam", email = "benjam@opendefence.fi" }, diff --git a/src/odmdm_connector/__init__.py b/src/odmdm_connector/__init__.py index ce54fa3..b77d48c 100644 --- a/src/odmdm_connector/__init__.py +++ b/src/odmdm_connector/__init__.py @@ -1,3 +1,3 @@ """Connects an MDM, FleetDM built in, to an OpenDefence deployment's SCEP device enrolment""" -__version__ = "1.5.0+261122" # NOTE Use `bump-my-version` to bump versions correctly +__version__ = "1.6.0+261123" # NOTE Use `bump-my-version` to bump versions correctly diff --git a/tests/test_odmdm_connector.py b/tests/test_odmdm_connector.py index 44443ce..e026256 100644 --- a/tests/test_odmdm_connector.py +++ b/tests/test_odmdm_connector.py @@ -5,4 +5,4 @@ def test_version() -> None: """Make sure version matches expected""" - assert __version__ == "1.5.0+261122" + assert __version__ == "1.6.0+261123" diff --git a/uv.lock b/uv.lock index 77e9c01..c811bde 100644 --- a/uv.lock +++ b/uv.lock @@ -923,7 +923,7 @@ wheels = [ [[package]] name = "odmdm-connector" -version = "1.5.0+261122" +version = "1.6.0+261123" source = { editable = "." } dependencies = [ { name = "keyring" },