From 12bfed37d4d22319e2cfadb5d9b460da7e748432 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Fri, 30 Sep 2011 10:09:55 +0200 Subject: Add a function for formatting network locations of the form host:port for use in URLs. If the host part is a literal IPv6 address, it must be enclosed in square brackets (RFC 2732). ticket 1869 --- ipa-client/ipaclient/ipadiscovery.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ipa-client/ipaclient') diff --git a/ipa-client/ipaclient/ipadiscovery.py b/ipa-client/ipaclient/ipadiscovery.py index f6c13fb67..3e31cad37 100644 --- a/ipa-client/ipaclient/ipadiscovery.py +++ b/ipa-client/ipaclient/ipadiscovery.py @@ -25,7 +25,7 @@ import tempfile import ldap from ldap import LDAPError from ipapython.ipautil import run, CalledProcessError, valid_ip, get_ipa_basedn, \ - realm_to_suffix + realm_to_suffix, format_netloc NOT_FQDN = -1 @@ -220,15 +220,15 @@ class IPADiscovery: raise RuntimeError("Creating temporary directory failed: %s" % str(e)) try: - run(["/usr/bin/wget", "-O", "%s/ca.crt" % temp_ca_dir, "http://%s/ipa/config/ca.crt" % thost]) + run(["/usr/bin/wget", "-O", "%s/ca.crt" % temp_ca_dir, "http://%s/ipa/config/ca.crt" % format_netloc(thost)]) except CalledProcessError, e: logging.debug('Retrieving CA from %s failed.\n%s' % (thost, str(e))) return [NOT_IPA_SERVER] #now verify the server is really an IPA server try: - logging.debug("Init ldap with: ldap://"+thost+":389") - lh = ldap.initialize("ldap://"+thost+":389") + logging.debug("Init ldap with: ldap://"+format_netloc(thost, 389)) + lh = ldap.initialize("ldap://"+format_netloc(thost, 389)) ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, True) ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, "%s/ca.crt" % temp_ca_dir) lh.set_option(ldap.OPT_PROTOCOL_VERSION, 3) -- cgit