Changeset c7000bb for skype/skyped.py


Ignore:
Timestamp:
2010-12-11T15:14:12Z (14 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
0b77a9b
Parents:
35249d6
Message:

Use internal ssl module instead of pyopenssl or python-gnutls

This results in shorter code and is available on Windows as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    r35249d6 rc7000bb  
    3333from ConfigParser import ConfigParser, NoOptionError
    3434from traceback import print_exception
     35import ssl
    3536
    3637__version__ = "0.1.1"
     
    8687def server(host, port):
    8788        global options
    88         try:
    89                 if "SKYPED_NO_GNUTLS" in os.environ.keys():
    90                         dprint("Warning, using OpenSSL instead of gnutls as requested (not recommended).")
    91                         raise ImportError
    92                 from gnutls import crypto, connection
    93                 cert = crypto.X509Certificate(open(options.config.sslcert).read())
    94                 key = crypto.X509PrivateKey(open(options.config.sslkey).read())
    95                 cred = connection.X509Credentials(cert, key)
    96                 sock = connection.ServerSessionFactory(socket.socket(), cred)
    97         except ImportError:
    98                 from OpenSSL import SSL
    99                 ctx = SSL.Context(SSL.TLSv1_METHOD)
    100                 ctx.use_privatekey_file(options.config.sslkey)
    101                 ctx.use_certificate_file(options.config.sslcert)
    102                 sock = SSL.Connection(ctx, socket.socket())
     89        sock = socket.socket()
    10390        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    10491        sock.bind((host, port))
     
    10895def listener(sock, *args):
    10996        global options
    110         options.conn, addr = sock.accept()
     97        rawsock, addr = sock.accept()
     98        options.conn = ssl.wrap_socket(rawsock,
     99                server_side=True,
     100                certfile=options.config.sslcert,
     101                keyfile=options.config.sslkey,
     102                ssl_version=ssl.PROTOCOL_TLSv1)
    111103        if hasattr(options.conn, 'handshake'):
    112104                try:
Note: See TracChangeset for help on using the changeset viewer.