Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificate enrollment: Fixes for LDAP searches and for some issues with multiple domain environments #1185

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

denisonbarbosa
Copy link
Member

This PR handles some issues encountered during certificate auto-enrollment on environments with multiple domains. Specific details for the fixes are listed on their respective commit messages, so I highly recommend looking at those.

Closes #1108
UDENG-4835

In the log output, there were several line breaks that were being
escaped (i.e. '\\n'), which was preventing them from being properly
printed. Fixing this allows for a better debugging experience and
clearer output.
@denisonbarbosa denisonbarbosa marked this pull request as ready for review January 31, 2025 15:09
@denisonbarbosa denisonbarbosa requested a review from a team as a code owner January 31, 2025 15:09
@denisonbarbosa denisonbarbosa changed the title Improvements to certificate auto-enrollment Certificate enrollment: Fixes for LDAP searches and for some issues with multiple domain environments Jan 31, 2025
The previous implementation tried to autodiscover the CEPCES server to
which it should connect to and fetch the templates for a specific CA.
However, it was setup in a way which would always override what was
configured in the cepces config file.

This was problematic as it was always assuming that the CEPCES server
was the same as the CA source, which isn't always the case.

These changes now allow us to override this behavior through the
cepces.conf file or keep it as is, provided that the configuration file
is the default one.

This also improves the output and error handling of the process, as it
didn't return any kind of message when failing to parse the templates
properly.
Some of the LDAP queries, although working on simple single-domain
environments, were causing problems on more complex ones (multiple
domains). This refines some of the queries to properly handle both cases
using the values that they should be using.
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Good work on this daunting task! I only have few requests!

ext.enroll(guid, entries, trust_dir, private_dir)
enrolled_cas = ext.enroll(guid, entries, trust_dir, private_dir)
if enrolled_cas is None:
log.warning('Could not enroll to any certificates')
Copy link
Member

Choose a reason for hiding this comment

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

"any certificate servers" (or service), rather?

@@ -191,14 +194,31 @@ def get_supported_templates(server):
log.error('Failed to find cepces-submit')
return []

cepces_config = configparser.ConfigParser()
Copy link
Member

Choose a reason for hiding this comment

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

that brings me back some nostalgia :)

p = Popen(cepces_args, env=env, stdout=PIPE, stderr=PIPE)
out, err = bytes(), bytes()
try:
out, err = p.communicate(timeout=3)
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a comment on the need for timeout. (could be stuck forever)

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.

Issue: LDAP error 32 LDAP_NO_SUCH_OBJECT
2 participants