Changeset b0d40f5 for skype/skyped.py


Ignore:
Timestamp:
2008-04-30T23:57:49Z (12 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
e3d0b10
Parents:
4c340e9
Message:

add python-gnutls support and make it default if available

  • this change in general should be ok, since openssl has problems when using it from gpl software which is distributed as a binary.
  • anyway, i hope that this will solve that magic "Fatal Python error: PyEval_RestoreThread: NULL tstate" error. at least it worth a try.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    r4c340e9 rb0d40f5  
    7474def server(host, port):
    7575        global options
    76 
    77         from OpenSSL import SSL
    78         ctx = SSL.Context(SSL.TLSv1_METHOD)
    79         ctx.use_privatekey_file(options.config.sslkey)
    80         ctx.use_certificate_file(options.config.sslcert)
    81         sock = SSL.Connection(ctx, socket.socket())
    82 
     76        try:
     77                if "SKYPED_NO_GNUTLS" in os.environ.keys():
     78                        dprint("Warning, using OpenSSL instead of gnutls as requested (not recommended).")
     79                        raise ImportError
     80                from gnutls import crypto, connection
     81                cert = crypto.X509Certificate(open(options.config.sslcert).read())
     82                key = crypto.X509PrivateKey(open(options.config.sslkey).read())
     83                cred = connection.X509Credentials(cert, key)
     84                sock = connection.ServerSessionFactory(socket.socket(), cred)
     85        except ImportError:
     86                from OpenSSL import SSL
     87                ctx = SSL.Context(SSL.TLSv1_METHOD)
     88                ctx.use_privatekey_file(options.config.sslkey)
     89                ctx.use_certificate_file(options.config.sslcert)
     90                sock = SSL.Connection(ctx, socket.socket())
    8391        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    8492        sock.bind((host, port))
     
    8997        global options
    9098        options.conn, addr = sock.accept()
     99        if hasattr(options.conn, 'handshake'):
     100                options.conn.handshake()
    91101        ret = 0
    92102        line = options.conn.recv(1024)
Note: See TracChangeset for help on using the changeset viewer.