Pastebin

Paste #424: secure_connection

< previous paste - next paste>

Pasted by tdn

Download View as text

def secure_connection(connection, key_file=None, cert_file=None):
    """Add a layer of security on top of the supplied connection.
    Please note that this _may_ only work for client to server
    connections!
    """
    if key_file or cert_file:
        print "using key %s and cert %s" % (key_file, cert_file)
        ssl_connection = socket.ssl(connection, key_file, cert_file)
    else:
        print "NOT using key and cert"
        ssl_connection = socket.ssl(connection)
    return ssl_connection

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.