From 5afacd39d3eb87f29a810f7434a27ac1dcf9edd2 Mon Sep 17 00:00:00 2001 From: William Brown Date: Jan 31 2020 02:09:45 +0000 Subject: Ticket 50859 - support running only with ldaps socket Bug Description: As plaintext protocols have shown they are unable to be effectively secured, we should have the choice to be able to run the server only as LDAPS for high assurance environments. Fix Description: Add a test to assert we can move to ldaps only and back to ldap/ldaps. Add a command to help make this easier for admins to find and discover. https://pagure.io/389-ds-base/issue/50859 Author: William Brown Review by: mreynolds (Thanks!) --- diff --git a/dirsrvtests/tests/suites/tls/tls_ldaps_only_test.py b/dirsrvtests/tests/suites/tls/tls_ldaps_only_test.py new file mode 100644 index 0000000..4bb5989 --- /dev/null +++ b/dirsrvtests/tests/suites/tls/tls_ldaps_only_test.py @@ -0,0 +1,46 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2020 William Brown config replace nsslapd-port='") + + def cert_add(inst, basedn, log, args): """Add server certificate """ @@ -367,6 +376,10 @@ def create_parser(subparsers): 'Turn off security functionality. The rest of the configuration will be left untouched.')) security_disable_p.set_defaults(func=security_disable) + security_disable_plain_parser = security_sub.add_parser('disable_plain_port', + help="Disables the plain text LDAP port, allowing only LDAPS to function") + security_disable_plain_parser.set_defaults(func=security_disable_plaintext_port) + # Server certificate management certs = security_sub.add_parser('certificate', help='Manage TLS certificates') certs_sub = certs.add_subparsers(help='certificate') diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py index f71baf2..a2f0159 100644 --- a/src/lib389/lib389/config.py +++ b/src/lib389/lib389/config.py @@ -213,6 +213,19 @@ class Config(DSLdapObject): report['fix'] = report['fix'].replace('YOUR_INSTANCE', self._instance.serverid) yield report + def disable_plaintext_port(self): + """ + Configure the server to not-provide the plaintext port. + """ + self.set('nsslapd-port', '0') + + def enable_plaintext_port(self, port): + """ + Configure the server to provide the plaintext port on the specified port number. + """ + self.set('nsslapd-port', port) + + class Encryption(DSLdapObject): """ Manage "cn=encryption,cn=config" tree, including: