aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2010-12-11 16:14:12 +0100
committerMiklos Vajna <vmiklos@frugalware.org>2010-12-11 16:14:12 +0100
commitc7000bbd6e5e44a75dba0a4c5a8e584a34b844b3 (patch)
tree7a4177c5292853e7fcacc11184e9eca75e215f42
parent35249d64faaad5d581448a52e439b643d6e6a2d3 (diff)
Use internal ssl module instead of pyopenssl or python-gnutls
This results in shorter code and is available on Windows as well.
-rw-r--r--skype/README27
-rw-r--r--skype/skyped.py24
2 files changed, 9 insertions, 42 deletions
diff --git a/skype/README b/skype/README
index 389e7411..9f18ddf2 100644
--- a/skype/README
+++ b/skype/README
@@ -40,7 +40,6 @@ not..)
* Python >= 2.5. Skype4Py does not work with 2.4.
* PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to
install GTK for nothing, right?)
-* pyopenssl or python-gnutls.
`bitlbee-skype` has been tested under Linux and Mac OS X. Skype and Skype4py is
available under Windows, too, so it probably works, but this has not been tested.
@@ -89,7 +88,7 @@ just append install-dev after install-etc.
# port -v install py25-gobject
----
-and you have to install `bitlbee-skype`, `skype4py` and `python-gnutls` from
+and you have to install `bitlbee-skype` and `skype4py` from
source.
=== Installing from source
@@ -125,23 +124,6 @@ $ cd Skype4Py-x.x.x.x
# python setup.py install
----
-- To install http://pypi.python.org/pypi/python-gnutls[python-gnutls] from source
- (unless you want to install the plugin for a public server):
-
-----
-$ tar -zxvf python-gnutls-x.x.x.tar.gz
-$ cd python-gnutls-x.x.x
-# python setup.py install
-----
-
-NOTE: On OS X you will need the following hacks first:
-
-----
-$ export LD_LIBRARY_PATH=/opt/local/lib
-$ export CFLAGS="-I/opt/local/include"
-$ export LDFLAGS="-L/opt/local/lib"
-----
-
- Get the plugin code (in an empty dir, or whereever you want, it does
not matter):
@@ -190,13 +172,6 @@ TIP: In case you have difficulties generating `skyped.cert.pem` /
contents of those files from
http://code.google.com/p/gdata-python-client/source/browse/src/gdata/oauth/rsa.py#87[here].
-- If both pyopenssl and python-gnutls are available, then python-gnutls
- will be used. This behaviour can be overwritten by:
-
-----
-$ export SKYPED_NO_GNUTLS=1
-----
-
- Start `skyped` (the tcp server):
----
diff --git a/skype/skyped.py b/skype/skyped.py
index 78885285..8ce35777 100644
--- a/skype/skyped.py
+++ b/skype/skyped.py
@@ -32,6 +32,7 @@ import Skype4Py
import hashlib
from ConfigParser import ConfigParser, NoOptionError
from traceback import print_exception
+import ssl
__version__ = "0.1.1"
@@ -85,21 +86,7 @@ def bitlbee_idle_handler(skype):
def server(host, port):
global options
- try:
- if "SKYPED_NO_GNUTLS" in os.environ.keys():
- dprint("Warning, using OpenSSL instead of gnutls as requested (not recommended).")
- raise ImportError
- from gnutls import crypto, connection
- cert = crypto.X509Certificate(open(options.config.sslcert).read())
- key = crypto.X509PrivateKey(open(options.config.sslkey).read())
- cred = connection.X509Credentials(cert, key)
- sock = connection.ServerSessionFactory(socket.socket(), cred)
- except ImportError:
- from OpenSSL import SSL
- ctx = SSL.Context(SSL.TLSv1_METHOD)
- ctx.use_privatekey_file(options.config.sslkey)
- ctx.use_certificate_file(options.config.sslcert)
- sock = SSL.Connection(ctx, socket.socket())
+ sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((host, port))
sock.listen(1)
@@ -107,7 +94,12 @@ def server(host, port):
def listener(sock, *args):
global options
- options.conn, addr = sock.accept()
+ rawsock, addr = sock.accept()
+ options.conn = ssl.wrap_socket(rawsock,
+ server_side=True,
+ certfile=options.config.sslcert,
+ keyfile=options.config.sslkey,
+ ssl_version=ssl.PROTOCOL_TLSv1)
if hasattr(options.conn, 'handshake'):
try:
options.conn.handshake()