diff options
Diffstat (limited to 'cpp/config/convertssl.py')
-rwxr-xr-x | cpp/config/convertssl.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/cpp/config/convertssl.py b/cpp/config/convertssl.py index 21675eda874..54cebe82d32 100755 --- a/cpp/config/convertssl.py +++ b/cpp/config/convertssl.py @@ -26,10 +26,10 @@ import sys, xml.dom, xml.dom.minidom # Show usage information. # def usage(): - print "Usage: " + sys.argv[0] + " xmlfile" - print - print "Options:" - print "-h Show this message." + print("Usage: " + sys.argv[0] + " xmlfile") + print("") + print("Options:") + print("-h Show this message.") def isCygwin(): # The substring on sys.platform is required because some cygwin @@ -56,20 +56,20 @@ def printConfig(node, name, comment=""): result = result + "#\n# NOTE: You may need to define IceSSL.DefaultDir\n" general = findChild(node, "general") if general: - if general.attributes.has_key("version"): + if "version" in general.attributes: version = general.attributes["version"].nodeValue if version == "SSLv3": result = result + prefix + "Protocols=SSLv3\n" elif version == "TLSv1": result = result + prefix + "Protocols=TLSv1\n" elif version != "SSLv23": - print "unknown value `" + version + "' for version attribute" + print("unknown value `" + version + "' for version attribute") sys.exit(1) - if general.attributes.has_key("cipherlist"): + if "cipherlist" in general.attributes: result = result + prefix + "Ciphers=" + general.attributes["cipherlist"].nodeValue + "\n" - if general.attributes.has_key("verifymode"): + if "verifymode" in general.attributes: verifymode = general.attributes["verifymode"].nodeValue if verifymode == "none": result = result + prefix + "VerifyPeer=0\n" @@ -80,21 +80,21 @@ def printConfig(node, name, comment=""): elif verifymode.find("client_once") != -1: result = result + prefix + "VerifyPeer=2\n" else: - print "unknown value `" + verifymode + "' for verifymode attribute" + print("unknown value `" + verifymode + "' for verifymode attribute") sys.exit(1) - if general.attributes.has_key("verifydepth"): + if "verifydepth" in general.attributes: result = result + prefix + "VerifyDepthMax=" + general.attributes["verifydepth"].nodeValue + "\n" - if general.attributes.has_key("randombytes"): + if "randombytes" in general.attributes: result = result + "# NOTE: You may need to use IceSSL.EntropyDaemon\n" result = result + prefix + "Random=" + general.attributes["randombytes"].nodeValue + "\n" ca = findChild(node, "certauthority") if ca: - if ca.attributes.has_key("file"): + if "file" in ca.attributes: result = result + prefix + "CertAuthFile=" + ca.attributes["file"].nodeValue + "\n" - if ca.attributes.has_key("path"): + if "path" in ca.attributes: result = result + prefix + "CertAuthDir=" + ca.attributes["path"].nodeValue + "\n" basecerts = findChild(node, "basecerts") @@ -104,33 +104,33 @@ def printConfig(node, name, comment=""): rsacert = findChild(basecerts, "rsacert") if rsacert: pub = findChild(rsacert, "public") - if pub.attributes.has_key("encoding"): + if "encoding" in pub.attributes: if pub.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for certificates!\n" - if pub.attributes.has_key("filename"): + if "filename" in pub.attributes: certFile = pub.attributes["filename"].nodeValue priv = findChild(rsacert, "private") - if priv.attributes.has_key("encoding"): + if "encoding" in priv.attributes: if priv.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for private keys!\n" - if priv.attributes.has_key("filename"): + if "filename" in priv.attributes: keyFile = priv.attributes["filename"].nodeValue dsacert = findChild(basecerts, "dsacert") if dsacert: pub = findChild(dsacert, "public") - if pub.attributes.has_key("encoding"): + if "encoding" in pub.attributes: if pub.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for certificates!\n" - if pub.attributes.has_key("filename"): + if "filename" in pub.attributes: if len(certFile) > 0: certFile = certFile + sep + pub.attributes["filename"].nodeValue else: certFile = pub.attributes["filename"].nodeValue priv = findChild(rsacert, "private") - if priv.attributes.has_key("encoding"): + if "encoding" in priv.attributes: if priv.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for private keys!\n" - if priv.attributes.has_key("filename"): + if "filename" in priv.attributes: if len(keyFile) > 0: keyFile = keyFile + sep + priv.attributes["filename"].nodeValue else: @@ -143,7 +143,7 @@ def printConfig(node, name, comment=""): for child in basecerts.childNodes: if child.localName == "dhparams": keysize = child.attributes["keysize"].nodeValue - if child.attributes.has_key("encoding"): + if "encoding" in child.attributes: if child.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for DH parameters!\n" filename = child.attributes["filename"].nodeValue @@ -160,8 +160,8 @@ for x in sys.argv[1:]: usage() sys.exit(0) elif x.startswith("-"): - print sys.argv[0] + ": unknown option `" + x + "'" - print + print(sys.argv[0] + ": unknown option `" + x + "'") + print("") usage() sys.exit(1) else: @@ -180,16 +180,16 @@ f.close() config = findChild(doc, "SSLConfig") if not config: - print sys.argv[0] + ": unable to find element SSLConfig" + print(sys.argv[0] + ": unable to find element SSLConfig") sys.exit(1) client = findChild(config, "client") server = findChild(config, "server") output = None if client and server: - print printConfig(client, "Client") - print printConfig(server, "Server", "#") + print(printConfig(client, "Client")) + print(printConfig(server, "Server", "#")) elif client: - print printConfig(client, "Client") + print(printConfig(client, "Client")) elif server: - print printConfig(server, "Server") + print(printConfig(server, "Server")) |