apply pyOpenSSL-0.8.patch from Marc-Andre Lemburg
diff --git a/src/crypto/crypto.c b/src/crypto/crypto.c
index d239a3b..a2b62c4 100644
--- a/src/crypto/crypto.c
+++ b/src/crypto/crypto.c
@@ -734,7 +734,7 @@
     for (i = 0; i < CRYPTO_num_locks(); ++i) {
         mutex_buf[i] = PyThread_allocate_lock();
     }
-    CRYPTO_set_id_callback(PyThread_get_thread_ident);
+    CRYPTO_set_id_callback((unsigned long (*)(void))PyThread_get_thread_ident);
     CRYPTO_set_locking_callback(locking_function);
     return 1;
 }
diff --git a/src/crypto/x509.c b/src/crypto/x509.c
index cc56c2c..b957f2d 100644
--- a/src/crypto/x509.c
+++ b/src/crypto/x509.c
@@ -365,7 +365,7 @@
 		ASN1_GENERALIZEDTIME dummy;
 		dummy.type = V_ASN1_GENERALIZEDTIME;
 		dummy.length = strlen(when);
-		dummy.data = when;
+		dummy.data = (unsigned char *)when;
 		if (!ASN1_GENERALIZEDTIME_check(&dummy)) {
 			PyErr_SetString(PyExc_ValueError, "Invalid string");
 		} else {
@@ -440,14 +440,14 @@
 	    Py_INCREF(Py_None);
 	    return Py_None;
 	} else if (timestamp->type == V_ASN1_GENERALIZEDTIME) {
-		return PyString_FromString(timestamp->data);
+	    return PyString_FromString((char *)timestamp->data);
 	} else {
 		ASN1_TIME_to_generalizedtime(timestamp, &gt_timestamp);
 		if (gt_timestamp == NULL) {
 			exception_from_error_queue();
 			return NULL;
 		} else {
-			py_timestamp = PyString_FromString(gt_timestamp->data);
+		    py_timestamp = PyString_FromString((char *)gt_timestamp->data);
 			ASN1_GENERALIZEDTIME_free(gt_timestamp);
 			return py_timestamp;
 		}
@@ -652,7 +652,7 @@
     unsigned char fp[EVP_MAX_MD_SIZE];
     char *tmp;
     char *digest_name;
-    int len,i;
+    unsigned int len,i;
     PyObject *ret;
     const EVP_MD *digest;
 
diff --git a/src/crypto/x509name.c b/src/crypto/x509name.c
index d304591..5402b3d 100644
--- a/src/crypto/x509name.c
+++ b/src/crypto/x509name.c
@@ -13,7 +13,7 @@
 #define crypto_MODULE
 #include "crypto.h"
 
-static PyMethodDef crypto_X509Name_methods[];
+static PyMethodDef crypto_X509Name_methods[4];
 
 /*
  * Constructor for X509Name, never called by Python code directly
@@ -102,8 +102,9 @@
     }
 
     /* Add the new entry */
-    if (!X509_NAME_add_entry_by_NID(name, nid, MBSTRING_UTF8, utf8string,
-                -1, -1, 0))
+    if (!X509_NAME_add_entry_by_NID(name, nid, MBSTRING_UTF8, 
+				    (unsigned char *)utf8string,
+				    -1, -1, 0))
     {
         exception_from_error_queue();
         return -1;
@@ -193,9 +194,8 @@
         return -1;
     } else if (result > 0) {
         return 1;
-    } else if (result == 0) {
+    } else
         return 0;
-    }
 }
 
 /*
@@ -318,7 +318,7 @@
 
 	tuple = PyTuple_New(2);
 	PyTuple_SetItem(tuple, 0, PyString_FromString(OBJ_nid2sn(nid)));
-	PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(str, l));
+	PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize((char *)str, l));
 
 	PyList_SetItem(list, i, tuple);
     }
diff --git a/src/ssl/context.c b/src/ssl/context.c
index 00785d6..1fecc9b 100644
--- a/src/ssl/context.c
+++ b/src/ssl/context.c
@@ -11,6 +11,12 @@
  */
 #include <Python.h>
 
+#if PY_VERSION_HEX >= 0x02050000
+# define PYARG_PARSETUPLE_FORMAT const char
+#else
+# define PYARG_PARSETUPLE_FORMAT char
+#endif
+
 #ifndef MS_WINDOWS
 #  include <sys/socket.h>
 #  include <netinet/in.h>
@@ -156,7 +162,7 @@
     SSL *ssl;
     ssl_ConnectionObj *conn;
     crypto_X509Obj *cert;
-    int errnum, errdepth, c_ret, use_thread_state;
+    int errnum, errdepth, c_ret;
 
     // Get Connection object to check thread state
     ssl = (SSL *)X509_STORE_CTX_get_app_data(x509_ctx);
@@ -197,7 +203,7 @@
  * Returns:   None
  */
 static void
-global_info_callback(SSL *ssl, int where, int _ret)
+global_info_callback(const SSL *ssl, int where, int _ret)
 {
     ssl_ConnectionObj *conn = (ssl_ConnectionObj *)SSL_get_app_data(ssl);
     PyObject *argv, *ret;
@@ -343,7 +349,7 @@
 
     if (!crypto_X509_type)
     {
-	if (!PyArg_ParseTuple(args, format1, &cert))
+	if (!PyArg_ParseTuple(args, (PYARG_PARSETUPLE_FORMAT *)format1, &cert))
 	    return NULL;
 
 	if (strcmp(cert->ob_type->tp_name, "X509") != 0 || 
@@ -356,7 +362,7 @@
 	crypto_X509_type = cert->ob_type;
     }
     else
-	if (!PyArg_ParseTuple(args, format2, crypto_X509_type,
+	if (!PyArg_ParseTuple(args, (PYARG_PARSETUPLE_FORMAT *)format2, crypto_X509_type,
 			      &cert))
 	    return NULL;
     return cert;
@@ -640,8 +646,8 @@
 static PyObject *
 ssl_Context_set_session_id(ssl_ContextObj *self, PyObject *args)
 {
-    char *buf;
-    int len;
+    unsigned char *buf;
+    unsigned int len;
 
     if (!PyArg_ParseTuple(args, "s#:set_session_id", &buf, &len))
         return NULL;