@davoodmehraban89 / LifeMate / commits / 62741da
Fork 0

LifeMate — Personal, Family & Learning Companion

fix: inspect every common-name value in debug signing certificates

Quinn White committed Oct 23, 2026 at 10:52 UTC 62741da7861921517541efafedae5514912fefe4
3 files changed +47 -4
docs/superpowers/plans/2026-10-23-local-signing-preflight.md
+13 -2
@@ -74,5 +74,16 @@ PR45; no merge/release/deploy. Stop after handover.
74 costs missing Windows legacy-guard coverage, not weaker Android release gates.
75 - Local full regression: 90 tests in32.576s OK (55 recovery +35 signing), inherited
76 host82 in0.197s OK; source compile and `git diff --check` exit0.
77 -- Task3: CI and independent review pending; no owner key/device/data inspection,
78 - config/signing/build/APK/merge/deploy/DNS performed by this packet.
77 +- Task3: independent review ran signing35/27.656s OK. It reproduced one Minor
78 + multi-valued-RDN CN false-negative. Coordinator re-graded Important for accurate
79 + owner-facing key facts, fixed all CN-value enumeration; actual synthetic test
80 + RED1failure→GREEN1test/3subjects (positive multi-RDN/lowercase, negative OU).
81 + No deferred review findings. Full-suite result recorded in final evidence.
82 +- CI initial `39941563602`: signing35 PASS on Ubuntu and Windows (Windows one
83 + POSIX skip); Ubuntu inherited guard import failed missing cryptography. Added
84 + existing pinned requirement; `39941815472` then both jobs SUCCESS on `9df0c92`.
85 + Final CN-correction CI pending. Generic CI initial run superseded/cancelled by
86 + normal branch concurrency; not treated as test success.
87 +- No owner key/device/data inspection, signing/configuration, personal APK delivery,
88 + merge/deploy/DNS performed. Generic CI may build existing debug test artifacts;
89 + they are not an approved update to the installed personal APK.
scripts/java/LifeGuideKeyInspector.java
+15 -2
@@ -16,6 +16,8 @@ import java.security.cert.CertificateNotYetValidException;
16 import java.security.cert.X509Certificate;
17 import java.util.Arrays;
18 import java.util.HexFormat;
19 +import javax.naming.NamingEnumeration;
20 +import javax.naming.directory.Attribute;
21 import javax.naming.ldap.LdapName;
22 import javax.naming.ldap.Rdn;
23
@@ -178,8 +180,19 @@ public final class LifeGuideKeyInspector {
180 private static boolean debugCertificate(X509Certificate certificate) throws Exception {
181 LdapName name = new LdapName(certificate.getSubjectX500Principal().getName());
182 for (Rdn rdn : name.getRdns()) {
181 - if ("CN".equalsIgnoreCase(rdn.getType())
182 - && "Android Debug".equalsIgnoreCase(String.valueOf(rdn.getValue()))) return true;
183 + // A multi-valued RDN's primary type may be C/OU even when it has CN.
184 + NamingEnumeration<? extends Attribute> attributes = rdn.toAttributes().getAll();
185 + try {
186 + while (attributes.hasMore()) {
187 + Attribute attribute = attributes.next();
188 + if (!"CN".equalsIgnoreCase(attribute.getID())) continue;
189 + for (int index = 0; index < attribute.size(); index++) {
190 + if ("Android Debug".equalsIgnoreCase(String.valueOf(attribute.get(index)))) return true;
191 + }
192 + }
193 + } finally {
194 + attributes.close();
195 + }
196 }
197 return false;
198 }
scripts/tests/test_signing_java.py
+19
@@ -74,6 +74,25 @@ class SigningJavaTests(unittest.TestCase):
74 self.assertEqual(code, 0)
75 self.assertIs(report["debugCertificate"], True)
76
77 + def test_debug_cn_in_multivalued_rdn_and_non_cn_value(self):
78 + cases = (("CN=Android Debug+C=US,O=Android", True),
79 + ("CN=android debug+OU=QA,O=Example", True),
80 + ("CN=Fictional+OU=Android Debug,O=Example", False))
81 + fixture = self.fixtures
82 + for index, (subject, expected) in enumerate(cases):
83 + with self.subTest(case=index):
84 + path = fixture.directory / ("multivalue-" + str(index) + ".jks")
85 + fixture.keytool("-genkeypair", "-keystore", path, "-storetype", "JKS",
86 + "-alias", fixture.alias, "-keyalg", "EC", "-dname", subject,
87 + "-validity", "3650", "-noprompt",
88 + "-storepass:env", "LG_TEST_STORE_PASSWORD",
89 + "-keypass:env", "LG_TEST_KEY_PASSWORD")
90 + before = path.read_bytes()
91 + code, report = self.inspect(path)
92 + self.assertEqual(code, 0)
93 + self.assertIs(report["debugCertificate"], expected)
94 + self.assertEqual(path.read_bytes(), before)
95 +
96 def test_expired_certificate_is_reported_without_blocking_proof(self):
97 path = self.fixtures.directory / "expired.jks"
98 self.fixtures.create_key(path, "RSA", expired=True)