Skip to content

ldaps: add LDAPS support - #264

Open
shridhargadekar wants to merge 1 commit into
SSSD:masterfrom
shridhargadekar:cert_ldaps
Open

ldaps: add LDAPS support#264
shridhargadekar wants to merge 1 commit into
SSSD:masterfrom
shridhargadekar:cert_ldaps

Conversation

@shridhargadekar

Copy link
Copy Markdown
Contributor
  • Add export_root_ca_certificate() to ADHost, SambaHost, and IPAHost
  • Add CertUtils (client.cert) utility for system-level CA cert install into /etc/openldap/ldap.conf — works with adcli, realmd, ldapsearch
  • Add SSSDCommonConfiguration helpers: ad_use_ldaps(), samba_use_ldaps(), ipa_set_tls_cacert() for SSSD-specific LDAPS configuration

- Add export_root_ca_certificate() to ADHost, SambaHost, and IPAHost
- Add CertUtils (client.cert) utility for system-level CA cert install
  into /etc/openldap/ldap.conf — works with adcli, realmd, ldapsearch
- Add SSSDCommonConfiguration helpers: ad_use_ldaps(), samba_use_ldaps(),
  ipa_set_tls_cacert() for SSSD-specific LDAPS configuration
- Add SSSDCommonConfiguration helpers: ad_use_ldaps(), samba_use_ldaps(),
  ipa_set_tls_cacert() for SSSD-specific LDAPS configuration
- Fix ADHost.export_root_ca_certificate() to walk the cert chain from
  LocalMachine\My (Server Auth EKU) to its issuer in LocalMachine\Root,
  avoiding unrelated Microsoft root CAs; falls back to server cert for
  self-signed DC certs (no AD CS)
- Add CertUtils.install_ca_from_server() to fetch and install the root
  CA directly from the LDAPS port via openssl s_client

Signed-off-by: shridhargadekar <shridhar.always@gmail.com>

return self.__naming_context

def export_root_ca_certificate(self) -> str:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These functions doesn't belong in hosts, it should be in roles and actually already have this method for this.

You should also add it to the generic provider because realm join works for AD, Samba, and IPA, allowing you to write a single test for multiple topologies using TopologyGroup.AnyDC or AnyAD

truncate --size 0 /var/log/krb5kdc.log
""")

def export_root_ca_certificate(self) -> str:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Like the previous comment, this doesn't belong in hosts, it should be in roles, there is an IPACertifcateAuthority.get() which may work for the CA as well. This CertificateAuthority class should be extended.

self.adminpw: str = self.config.get("adminpw", self.bindpw)
"""Password of the admin user, defaults to value of ``bindpw``."""

self.ca_cert_path: str = self.config.get("ca_cert_path", "/var/data/certs/ca.crt")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as the previous comment, but this has no CertificateAuthority class. Please make each role a separate commit.

.. code-block:: python
:caption: Example usage with adcli

@pytest.mark.topology(KnownTopology.Samba)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this test scenario is really valid, since the KnownTopology.Samba is already joined when the test starts. Have you tried running this test?



class _HasCACert(Protocol):
"""Any host that can export its root CA certificate."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving to roles, this shouldn't be necessary.

def install_ca(
self,
host: _HasCACert,
name: str = "test-ldap-ca.crt",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick, the ca.crt doesn't have to be used for ldap, I'd omit ldap from the name.

self.sssd.fs.mkdir_p(parent)
self.sssd.fs.write(cacert_path, ca_cert)

def ad_use_ldaps(self, ad: AD, cacert_path: str = "/etc/sssd/pki/ad-ca.crt") -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We already have a method to configure ldap, SSSDCommonConfiugration.ldap_provider, instead of adding three new methods, please extend this method to support ldaps.

def ldap_provider(
    self,
    server: str,
    naming_context: str,
    bind_user_dn: str,
    bind_password: str,
    subids: bool = False,
    cacert: str = "/etc/ipa/ca.crt",
    tls_reqcert: str = "demand",
    ssl: bool = False,
    config: dict[str, str] | None = None,
) -> None:

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.

3 participants