Skip to content

Conversation

@touilleMan
Copy link
Contributor

No description provided.

@touilleMan touilleMan force-pushed the async-enrollment-postgres branch from b3a7e3c to 1475f27 Compare January 6, 2026 15:16
@touilleMan touilleMan marked this pull request as ready for review January 6, 2026 15:17
@touilleMan touilleMan requested a review from a team as a code owner January 6, 2026 15:17
@touilleMan touilleMan force-pushed the async-enrollment-postgres branch from 1475f27 to 33d94da Compare January 6, 2026 15:33
@touilleMan touilleMan force-pushed the async-enrollment-transit-mount-path branch from 54a5869 to a0122c1 Compare January 7, 2026 15:35
@touilleMan touilleMan requested review from a team as code owners January 7, 2026 15:35
@touilleMan touilleMan force-pushed the async-enrollment-postgres branch from 33d94da to b475f78 Compare January 7, 2026 15:37
@touilleMan touilleMan force-pushed the async-enrollment-transit-mount-path branch from a0122c1 to bf6df65 Compare January 8, 2026 08:50
@touilleMan touilleMan force-pushed the async-enrollment-postgres branch from b475f78 to 6af9a44 Compare January 8, 2026 08:50
""")


_q_insert_user_and_device = Q(f"""
Copy link
Contributor

@mmmarcos mmmarcos Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pki_accept this was implemented re-using _q_insert_user_and_device from user_create_user.py:

from parsec.components.postgresql.user_create_user import _q_insert_user_and_device

I know that we've started to prefer each component/command to define its own set of queries (specially when there are slightly differences between the needs of each command), BUT for complex queries like this one, the duplication introduces a significant risk of error IMO.

Since there seems to be no difference, why not reusing-it? The only potential issue I see is that it has to be clear when a query can be reused... we could move them to the queries directory which already contains "common" queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right on this, I've updated the code to directly use _q_insert_user_and_device 👍

# - Should not be longer than 10 items (including leaf and root)
# - Each intermediate certificate should be used exactly once

if len(intermediate_der_x509_certificates) > 8: # 8 since we exclude leaf and root
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the MAX_INTERMEDIATE_CERTIFICATES_DEPTH (the value is up to discussion)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, this also makes simpler to test this error case

return f"{self.__class__.__qualname__}(subject={self.subject}, issuer={self.issuer})"


def _validate_x509_trustchain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to have a look at build_trustchain

async def build_trustchain(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at it, and think it would be simpler to avoid using dictionary when checking the intermediary certificates:

  • the number of items is very small (and async enrollement APIs are not used often), so there is no performance concern
  • list(trustchain.values()) relies on the fact Python dictionaries retain insertion order, this is something implicit (and it has not been always the case), so I'd rather avoid it

On top of that, the fact PkiCertificate gets its signed_by attribute updated add complexity (since the object need to be mutable) and is not strictly needed (the fingerprint can be retrieved by iterating over the trustchain in the code doing the SQL query, which means quadratic complexity but again this is not an issue since the number of certificates is small)

Base automatically changed from async-enrollment-transit-mount-path to async-enrollment-client January 9, 2026 09:59
@touilleMan touilleMan force-pushed the async-enrollment-client branch from 7059f1f to c20c78b Compare January 9, 2026 10:55
@touilleMan touilleMan force-pushed the async-enrollment-postgres branch 2 times, most recently from a5f17d6 to 1b83563 Compare January 9, 2026 11:06
@touilleMan touilleMan requested a review from a team as a code owner January 9, 2026 11:06
Base automatically changed from async-enrollment-client to master January 9, 2026 12:06
@touilleMan touilleMan force-pushed the async-enrollment-postgres branch from 1b83563 to 17e4257 Compare January 9, 2026 12:38
@touilleMan touilleMan added this pull request to the merge queue Jan 9, 2026
Merged via the queue into master with commit 486485e Jan 9, 2026
17 checks passed
@touilleMan touilleMan deleted the async-enrollment-postgres branch January 9, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async enrollment: server-side basic X509 certificate chain check Async enrollment: server PostgreSQL implementation

4 participants