From kototama-code at altern.org Sun Feb 13 20:38:06 2005 From: kototama-code at altern.org (Kototama) Date: Sun, 13 Feb 2005 20:38:06 +0100 Subject: [pyOpenSSL] Pb blocking recv with select Message-ID: <420FAC9E.90909@altern.org> Hi, the following code (just taken on the example) blocks on recv unless I decomment the 'send' function. I tested it with stunnel. Select seems to tell that there is something to read whereas there is nothing. Moreover why does it block since I am in non blocking mode ? ----- from OpenSSL import SSL import sys, os, select, socket def verify_cb(conn, cert, errnum, depth, ok): # This obviously has to be updated print 'Got certificate: %s' % cert.get_subject() return ok if len(sys.argv) < 2: print 'Usage: python[2] server.py PORT' sys.exit(1) dir = os.path.dirname(sys.argv[0]) if dir == '': dir = os.curdir # Initialize context ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.set_options(SSL.OP_NO_SSLv2) ctx.set_verify(SSL.VERIFY_NONE, verify_cb) # Demand a certificate ctx.use_privatekey_file (os.path.join(dir, 'cert/server.pkey')) ctx.use_certificate_file(os.path.join(dir, 'cert/server.cert')) ctx.load_verify_locations(os.path.join(dir, 'cert/CA.cert')) # Set up server server = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) server.bind(('', int(sys.argv[1]))) server.listen(3) server.setblocking(0) clients = {} writers = {} def dropClient(cli, errors=None): if errors: print 'Client %s left unexpectedly:' % (clients[cli],) print ' ', errors else: print 'Client %s left politely' % (clients[cli],) del clients[cli] if writers.has_key(cli): del writers[cli] if not errors: cli.shutdown() cli.close() __cli = None while 1: print 'select' try: r,w,_ = select.select([server]+clients.keys(), writers.keys(), [], 1) except: break print '[ OK ]' for cli in r: if cli == server: cli,addr = server.accept() __cli = cli print 'Connection from %s' % (addr,) clients[cli] = addr else: try: print 'recv...' ######## we block here ########### ret = cli.recv(1024) print '[ OK ]' except (SSL.WantReadError, SSL.WantWriteError, SSL.WantX509LookupError): pass except SSL.ZeroReturnError: dropClient(cli) except SSL.Error, errors: dropClient(cli, errors) else: if not writers.has_key(cli): writers[cli] = '' writers[cli] = writers[cli] + ret # if we decomment this it is ok ###if __cli: ###print 'send' ###__cli.send('test\n') ###print '[ OK ]' for cli in w: try: ret = cli.send(writers[cli]) except (SSL.WantReadError, SSL.WantWriteError, SSL.WantX509LookupError): pass except SSL.ZeroReturnError: dropClient(cli) except SSL.Error, errors: dropClient(cli, errors) else: writers[cli] = writers[cli][ret:] if writers[cli] == '': del writers[cli] for cli in clients.keys(): cli.close() server.close() From itamar at itamarst.org Sun Feb 13 21:33:11 2005 From: itamar at itamarst.org (Itamar Shtull-Trauring) Date: Sun, 13 Feb 2005 15:33:11 -0500 Subject: [pyOpenSSL] Pb blocking recv with select In-Reply-To: <420FAC9E.90909@altern.org> References: <420FAC9E.90909@altern.org> Message-ID: <1108326792.1115.10.camel@sheriffpony> On Sun, 2005-02-13 at 20:38 +0100, Kototama wrote: > the following code (just taken on the example) blocks on recv unless I > decomment the 'send' function. I tested it with stunnel. Select seems to > tell that there is something to read whereas there is nothing. Moreover > why does it block since I am in non blocking mode ? Possibly it's because you're not handling the WantReadError/WantWriteError errors the right way. Check out how Twisted uses pyOpenSSL (or better yet, just use Twisted ;). From mike at pcblokes.com Wed Feb 16 15:02:25 2005 From: mike at pcblokes.com (Michael Foord) Date: Wed, 16 Feb 2005 14:02:25 +0000 Subject: [pyOpenSSL] Building PyOpenSSL for Windows Message-ID: <42135271.3080102@pcblokes.com> Hello, I'm attempting to build PyOpenSSL for windows. I'm currently attempting with mingw32 and Python2.3 - although I'd also like to do it with Python 2.4 and the windows optimising compiler. (Both windows XP) I'm currently struggling ! Using 'pyOpenSSL-0.6' source from Sourceforge and the windows prebuilt binaries for OpenSSL 0.9.7e. The 'install' file with pyOpenSSL says : Building the library: setup.py build_ext -I ...\openssl\inc32 -L ...\openssl\out32dll setup.py build (to which I had -cmingw32 to make distutils use gcc from mingw32) My opensssl installation has neither an inc32 directory, nor an out32dll file/directory. There is an `C:\OpenSSL\include\openssl` directory - with all the '.h' and '.c' files. There is also a directory 'C:\OpenSSL\lib\MinGW' with all the '.a' and '.def' files. I guessed at the following command line order - which failed with the following messages. Does anyone have any clues (or can point me to resources/prebuilt binaries) ? It fails with a 'no such file' error as the first error, yet that file exists in the openssl directory. I guess the rest of the errors relate to it not finding the include file. D:\Downloads\pyOpenSSL-0.6>setup.py build_ext -I C:\OpenSSL\include\openssl -L C :\OpenSSL\lib\MinGW -cmingw32 running build_ext building 'OpenSSL.crypto' extension creating build creating build\temp.win32-2.3 creating build\temp.win32-2.3\Release creating build\temp.win32-2.3\Release\src creating build\temp.win32-2.3\Release\src\crypto C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\OpenSSL\include\openssl -IC :\Python23\include -IC:\Python23\PC -c src/crypto/crypto.c -o build\temp.win32-2 .3\Release\src\crypto\crypto.o In file included from src/crypto/crypto.h:17, from src/crypto/crypto.c:13: src/crypto/x509.h:17:25: openssl/ssl.h: No such file or directory In file included from src/crypto/crypto.h:17, from src/crypto/crypto.c:13: src/crypto/x509.h:27: error: syntax error before "X509" src/crypto/x509.h:27: warning: no semicolon at end of struct or union src/crypto/x509.h:29: error: syntax error before '}' token src/crypto/x509.h:29: warning: type defaults to `int' in declaration of `crypto_ X509Obj' src/crypto/x509.h:29: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:18, from src/crypto/crypto.c:13: src/crypto/x509name.h:27: error: syntax error before "X509_NAME" src/crypto/x509name.h:27: warning: no semicolon at end of struct or union src/crypto/x509name.h:30: error: syntax error before '}' token src/crypto/x509name.h:30: warning: type defaults to `int' in declaration of `cry pto_X509NameObj' src/crypto/x509name.h:30: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:19, from src/crypto/crypto.c:13: src/crypto/netscape_spki.h:24: error: syntax error before "NETSCAPE_SPKI" src/crypto/netscape_spki.h:24: warning: no semicolon at end of struct or union src/crypto/netscape_spki.h:26: error: syntax error before '}' token src/crypto/netscape_spki.h:26: warning: type defaults to `int' in declaration of `crypto_NetscapeSPKIObj' src/crypto/netscape_spki.h:26: warning: data definition has no type or storage c lass In file included from src/crypto/crypto.h:20, from src/crypto/crypto.c:13: src/crypto/x509store.h:25: error: syntax error before "X509_STORE" src/crypto/x509store.h:25: warning: no semicolon at end of struct or union src/crypto/x509store.h:27: error: syntax error before '}' token src/crypto/x509store.h:27: warning: type defaults to `int' in declaration of `cr ypto_X509StoreObj' src/crypto/x509store.h:27: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:21, from src/crypto/crypto.c:13: src/crypto/x509req.h:25: error: syntax error before "X509_REQ" src/crypto/x509req.h:25: warning: no semicolon at end of struct or union src/crypto/x509req.h:27: error: syntax error before '}' token src/crypto/x509req.h:27: warning: type defaults to `int' in declaration of `cryp to_X509ReqObj' src/crypto/x509req.h:27: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:22, from src/crypto/crypto.c:13: src/crypto/pkey.h:22: error: syntax error before "EVP_PKEY" src/crypto/pkey.h:22: warning: no semicolon at end of struct or union src/crypto/pkey.h:24: error: syntax error before '}' token src/crypto/pkey.h:24: warning: type defaults to `int' in declaration of `crypto_ PKeyObj' src/crypto/pkey.h:24: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:23, from src/crypto/crypto.c:13: src/crypto/x509ext.h:16:28: openssl/x509v3.h: No such file or directory In file included from src/crypto/crypto.h:23, from src/crypto/crypto.c:13: src/crypto/x509ext.h:27: error: syntax error before "X509_EXTENSION" src/crypto/x509ext.h:27: warning: no semicolon at end of struct or union src/crypto/x509ext.h:29: error: syntax error before '}' token src/crypto/x509ext.h:29: warning: type defaults to `int' in declaration of `cryp to_X509ExtensionObj' src/crypto/x509ext.h:29: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:24, from src/crypto/crypto.c:13: src/crypto/pkcs7.h:15:27: openssl/pkcs7.h: No such file or directory In file included from src/crypto/crypto.h:24, from src/crypto/crypto.c:13: src/crypto/pkcs7.h:25: error: syntax error before "PKCS7" src/crypto/pkcs7.h:25: warning: no semicolon at end of struct or union src/crypto/pkcs7.h:27: error: syntax error before '}' token src/crypto/pkcs7.h:27: warning: type defaults to `int' in declaration of `crypto _PKCS7Obj' src/crypto/pkcs7.h:27: warning: data definition has no type or storage class In file included from src/crypto/crypto.h:25, from src/crypto/crypto.c:13: src/crypto/pkcs12.h:14:28: openssl/pkcs12.h: No such file or directory src/crypto/pkcs12.h:15:26: openssl/asn1.h: No such file or directory In file included from src/crypto/crypto.h:26, from src/crypto/crypto.c:13: src/crypto/../util.h:17:25: openssl/err.h: No such file or directory In file included from src/crypto/crypto.c:13: src/crypto/crypto.h:75: error: syntax error before '*' token src/crypto/crypto.h:75: error: syntax error before '*' token src/crypto/crypto.h:75: warning: type defaults to `int' in declaration of `crypt o_X509_New' src/crypto/crypto.h:75: warning: data definition has no type or storage class src/crypto/crypto.h:76: error: syntax error before '*' token src/crypto/crypto.h:76: error: syntax error before '*' token src/crypto/crypto.h:76: warning: type defaults to `int' in declaration of `crypt o_X509Name_New' src/crypto/crypto.h:76: warning: data definition has no type or storage class src/crypto/crypto.h:77: error: syntax error before '*' token src/crypto/crypto.h:77: error: syntax error before '*' token src/crypto/crypto.h:77: warning: type defaults to `int' in declaration of `crypt o_X509Req_New' src/crypto/crypto.h:77: warning: data definition has no type or storage class src/crypto/crypto.h:78: error: syntax error before '*' token src/crypto/crypto.h:78: error: syntax error before '*' token src/crypto/crypto.h:78: warning: type defaults to `int' in declaration of `crypt o_X509Store_New' src/crypto/crypto.h:78: warning: data definition has no type or storage class src/crypto/crypto.h:79: error: syntax error before '*' token src/crypto/crypto.h:79: error: syntax error before '*' token src/crypto/crypto.h:79: warning: type defaults to `int' in declaration of `crypt o_PKey_New' src/crypto/crypto.h:79: warning: data definition has no type or storage class src/crypto/crypto.h:80: error: syntax error before '*' token src/crypto/crypto.h:80: warning: type defaults to `int' in declaration of `crypt o_X509Extension_New' src/crypto/crypto.h:80: warning: data definition has no type or storage class src/crypto/crypto.h:81: error: syntax error before '*' token src/crypto/crypto.h:81: error: syntax error before '*' token src/crypto/crypto.h:81: warning: type defaults to `int' in declaration of `crypt o_PKCS7_New' src/crypto/crypto.h:81: warning: data definition has no type or storage class src/crypto/crypto.h:82: error: syntax error before '*' token src/crypto/crypto.h:82: error: syntax error before '*' token src/crypto/crypto.h:82: warning: type defaults to `int' in declaration of `crypt o_NetscapeSPKI_New' src/crypto/crypto.h:82: warning: data definition has no type or storage class src/crypto/crypto.c: In function `crypto_load_privatekey': src/crypto/crypto.c:66: error: `EVP_PKEY' undeclared (first use in this function ) src/crypto/crypto.c:66: error: (Each undeclared identifier is reported only once src/crypto/crypto.c:66: error: for each function it appears in.) src/crypto/crypto.c:66: error: syntax error before ',' token src/crypto/crypto.c:70: error: `pem_password_cb' undeclared (first use in this f unction) src/crypto/crypto.c:70: error: `cb' undeclared (first use in this function) src/crypto/crypto.c:72: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:72: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:73: error: `pkey' undeclared (first use in this function) src/crypto/crypto.c:97: warning: implicit declaration of function `BIO_new_mem_b uf' src/crypto/crypto.c:100: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:101: warning: implicit declaration of function `PEM_read_bio _PrivateKey' src/crypto/crypto.c:104: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:105: warning: implicit declaration of function `d2i_PrivateK ey_bio' src/crypto/crypto.c:110: warning: implicit declaration of function `BIO_free' src/crypto/crypto.c: In function `crypto_dump_privatekey': src/crypto/crypto.c:146: error: syntax error before '*' token src/crypto/crypto.c:148: error: `pem_password_cb' undeclared (first use in this function) src/crypto/crypto.c:148: error: `cb' undeclared (first use in this function) src/crypto/crypto.c:150: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:150: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:151: error: `pkey' undeclared (first use in this function) src/crypto/crypto.c:164: error: `cipher' undeclared (first use in this function) src/crypto/crypto.c:164: warning: implicit declaration of function `EVP_get_ciph erbyname' src/crypto/crypto.c:187: warning: implicit declaration of function `BIO_new' src/crypto/crypto.c:187: warning: implicit declaration of function `BIO_s_mem' src/crypto/crypto.c:190: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:191: warning: implicit declaration of function `PEM_write_bi o_PrivateKey' src/crypto/crypto.c:199: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:200: warning: implicit declaration of function `i2d_PrivateK ey_bio' src/crypto/crypto.c:216: warning: implicit declaration of function `BIO_get_mem_ data' src/crypto/crypto.c: In function `crypto_load_certificate': src/crypto/crypto.c:236: error: `X509' undeclared (first use in this function) src/crypto/crypto.c:236: error: syntax error before ',' token src/crypto/crypto.c:239: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:239: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:240: error: `cert' undeclared (first use in this function) src/crypto/crypto.c:248: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:249: warning: implicit declaration of function `PEM_read_bio _X509' src/crypto/crypto.c:252: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:253: warning: implicit declaration of function `d2i_X509_bio ' src/crypto/crypto.c: In function `crypto_dump_certificate': src/crypto/crypto.c:288: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:288: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:289: error: `cert' undeclared (first use in this function) src/crypto/crypto.c:298: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:299: warning: implicit declaration of function `PEM_write_bi o_X509' src/crypto/crypto.c:302: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:303: warning: implicit declaration of function `i2d_X509_bio ' src/crypto/crypto.c: In function `crypto_load_certificate_request': src/crypto/crypto.c:339: error: `X509_REQ' undeclared (first use in this functio n) src/crypto/crypto.c:339: error: syntax error before ',' token src/crypto/crypto.c:342: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:342: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:343: error: `req' undeclared (first use in this function) src/crypto/crypto.c:351: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:352: warning: implicit declaration of function `PEM_read_bio _X509_REQ' src/crypto/crypto.c:355: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:356: warning: implicit declaration of function `d2i_X509_REQ _bio' src/crypto/crypto.c: In function `crypto_dump_certificate_request': src/crypto/crypto.c:391: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:391: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:392: error: `req' undeclared (first use in this function) src/crypto/crypto.c:401: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:402: warning: implicit declaration of function `PEM_write_bi o_X509_REQ' src/crypto/crypto.c:405: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:406: warning: implicit declaration of function `i2d_X509_REQ _bio' src/crypto/crypto.c: In function `crypto_load_pkcs7_data': src/crypto/crypto.c:444: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:444: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:445: error: `PKCS7' undeclared (first use in this function) src/crypto/crypto.c:445: error: `pkcs7' undeclared (first use in this function) src/crypto/crypto.c:456: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:457: warning: implicit declaration of function `PEM_read_bio _PKCS7' src/crypto/crypto.c:460: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:461: warning: implicit declaration of function `d2i_PKCS7_bi o' src/crypto/crypto.c: In function `crypto_load_pkcs12': src/crypto/crypto.c:496: error: syntax error before '*' token src/crypto/crypto.c:499: error: `BIO' undeclared (first use in this function) src/crypto/crypto.c:499: error: `bio' undeclared (first use in this function) src/crypto/crypto.c:500: error: `PKCS12' undeclared (first use in this function) src/crypto/crypto.c:500: error: `p12' undeclared (first use in this function) src/crypto/crypto.c:506: warning: implicit declaration of function `d2i_PKCS12_b io' src/crypto/crypto.c: In function `crypto_X509': src/crypto/crypto.c:533: warning: implicit declaration of function `X509_new' src/crypto/crypto.c: In function `crypto_X509Name': src/crypto/crypto.c:549: error: `name' undeclared (first use in this function) src/crypto/crypto.c:554: warning: implicit declaration of function `X509_NAME_du p' src/crypto/crypto.c: In function `crypto_X509Req': src/crypto/crypto.c:572: warning: implicit declaration of function `X509_REQ_new ' src/crypto/crypto.c: In function `crypto_PKey': src/crypto/crypto.c:590: warning: implicit declaration of function `EVP_PKEY_new ' src/crypto/crypto.c: In function `crypto_NetscapeSPKI': src/crypto/crypto.c:633: error: `NETSCAPE_SPKI' undeclared (first use in this fu nction) src/crypto/crypto.c:633: error: `spki' undeclared (first use in this function) src/crypto/crypto.c:639: warning: implicit declaration of function `NETSCAPE_SPK I_b64_decode' src/crypto/crypto.c:641: warning: implicit declaration of function `NETSCAPE_SPK I_new' src/crypto/crypto.c: In function `initcrypto': src/crypto/crypto.c:684: warning: implicit declaration of function `ERR_load_cry pto_strings' src/crypto/crypto.c:685: warning: implicit declaration of function `OpenSSL_add_ all_algorithms' src/crypto/crypto.c:709: error: `X509_FILETYPE_PEM' undeclared (first use in thi s function) src/crypto/crypto.c:710: error: `X509_FILETYPE_ASN1' undeclared (first use in th is function) src/crypto/crypto.c:712: error: `EVP_PKEY_RSA' undeclared (first use in this fun ction) src/crypto/crypto.c:713: error: `EVP_PKEY_DSA' undeclared (first use in this fun ction) src/crypto/crypto.c: At top level: src/crypto/crypto.c:20: warning: 'CVSid' defined but not used error: command 'gcc' failed with exit status 1 Many Thanks Fuzzyman http://www.voidspace.org.uk/python/index.shtml From mike at pcblokes.com Wed Feb 16 15:21:46 2005 From: mike at pcblokes.com (Michael Foord) Date: Wed, 16 Feb 2005 14:21:46 +0000 Subject: [pyOpenSSL] Building for Windows - Take 2 Message-ID: <421356FA.8040307@pcblokes.com> directory and the include files to Attempting to build for windows - take 2. If I copy the '.a' and '.def' files to the 'C:\mingw32\lib''C:\mingw32\includes' - I get a very different error message. D:\Downloads\pyOpenSSL-0.6>setup.py build_ext -cmingw32 running build_ext building 'OpenSSL.crypto' extension creating build creating build\temp.win32-2.3 creating build\temp.win32-2.3\Release creating build\temp.win32-2.3\Release\src creating build\temp.win32-2.3\Release\src\crypto C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/crypto.c -o build\temp.win32-2.3\Release\src\crypto\crypto. o src/crypto/crypto.c:20: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkey.c -o build\temp.win32-2.3\Release\src\crypto\pkey.o src/crypto/pkey.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/netscape_spki.c -o build\temp.win32-2.3\Release\src\crypto\ netscape_spki.o src/crypto/netscape_spki.c:12: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509req.c -o build\temp.win32-2.3\Release\src\crypto\x509re q.o src/crypto/x509req.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs12.c -o build\temp.win32-2.3\Release\src\crypto\pkcs12. o src/crypto/pkcs12.c:17: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/util.c -o build\temp.win32-2.3\Release\src\util.o src/util.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509.c -o build\temp.win32-2.3\Release\src\crypto\x509.o src/crypto/x509.c:15: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs7.c -o build\temp.win32-2.3\Release\src\crypto\pkcs7.o src/crypto/pkcs7.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509store.c -o build\temp.win32-2.3\Release\src\crypto\x509 store.o src/crypto/x509store.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509ext.c -o build\temp.win32-2.3\Release\src\crypto\x509ex t.o src/crypto/x509ext.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509name.c -o build\temp.win32-2.3\Release\src\crypto\x509n ame.o src/crypto/x509name.c:15: warning: 'CVSid' defined but not used writing build\temp.win32-2.3\Release\src\crypto\crypto.def creating build\lib.win32-2.3 creating build\lib.win32-2.3\OpenSSL C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.3\Release\src\cry pto\crypto.o build\temp.win32-2.3\Release\src\crypto\x509.o build\temp.win32-2.3 \Release\src\crypto\x509name.o build\temp.win32-2.3\Release\src\crypto\pkey.o bu ild\temp.win32-2.3\Release\src\crypto\x509store.o build\temp.win32-2.3\Release\s rc\crypto\x509req.o build\temp.win32-2.3\Release\src\crypto\x509ext.o build\temp .win32-2.3\Release\src\crypto\pkcs7.o build\temp.win32-2.3\Release\src\crypto\pk cs12.o build\temp.win32-2.3\Release\src\crypto\netscape_spki.o build\temp.win32- 2.3\Release\src\util.o build\temp.win32-2.3\Release\src\crypto\crypto.def -LC:\P ython23\libs -LC:\Python23\PCBuild -llibeay32 -lssleay32 -lWs2_32 -lpython23 -o build\lib.win32-2.3\OpenSSL\crypto.pyd C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin d -llibeay32 collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 Any clues ? Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml From mike at pcblokes.com Wed Feb 16 16:42:19 2005 From: mike at pcblokes.com (Michael Foord) Date: Wed, 16 Feb 2005 15:42:19 +0000 Subject: [pyOpenSSL] Building for Windows - Take 2 Message-ID: <421369DB.4030008@pcblokes.com> Sorry - resend - I garbled the last message a bit. My apologies. Attempting to build for windows - take 2. If I copy the '.a' and '.def' files to the 'C:\mingw32\lib' directory and the include files to 'C:\mingw32\includes' - I get a very different error message. D:\Downloads\pyOpenSSL-0.6>setup.py build_ext -cmingw32 running build_ext building 'OpenSSL.crypto' extension creating build creating build\temp.win32-2.3 creating build\temp.win32-2.3\Release creating build\temp.win32-2.3\Release\src creating build\temp.win32-2.3\Release\src\crypto C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/crypto.c -o build\temp.win32-2.3\Release\src\crypto\crypto. o src/crypto/crypto.c:20: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkey.c -o build\temp.win32-2.3\Release\src\crypto\pkey.o src/crypto/pkey.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/netscape_spki.c -o build\temp.win32-2.3\Release\src\crypto\ netscape_spki.o src/crypto/netscape_spki.c:12: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509req.c -o build\temp.win32-2.3\Release\src\crypto\x509re q.o src/crypto/x509req.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs12.c -o build\temp.win32-2.3\Release\src\crypto\pkcs12. o src/crypto/pkcs12.c:17: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/util.c -o build\temp.win32-2.3\Release\src\util.o src/util.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509.c -o build\temp.win32-2.3\Release\src\crypto\x509.o src/crypto/x509.c:15: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs7.c -o build\temp.win32-2.3\Release\src\crypto\pkcs7.o src/crypto/pkcs7.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509store.c -o build\temp.win32-2.3\Release\src\crypto\x509 store.o src/crypto/x509store.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509ext.c -o build\temp.win32-2.3\Release\src\crypto\x509ex t.o src/crypto/x509ext.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509name.c -o build\temp.win32-2.3\Release\src\crypto\x509n ame.o src/crypto/x509name.c:15: warning: 'CVSid' defined but not used writing build\temp.win32-2.3\Release\src\crypto\crypto.def creating build\lib.win32-2.3 creating build\lib.win32-2.3\OpenSSL C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.3\Release\src\cry pto\crypto.o build\temp.win32-2.3\Release\src\crypto\x509.o build\temp.win32-2.3 \Release\src\crypto\x509name.o build\temp.win32-2.3\Release\src\crypto\pkey.o bu ild\temp.win32-2.3\Release\src\crypto\x509store.o build\temp.win32-2.3\Release\s rc\crypto\x509req.o build\temp.win32-2.3\Release\src\crypto\x509ext.o build\temp .win32-2.3\Release\src\crypto\pkcs7.o build\temp.win32-2.3\Release\src\crypto\pk cs12.o build\temp.win32-2.3\Release\src\crypto\netscape_spki.o build\temp.win32- 2.3\Release\src\util.o build\temp.win32-2.3\Release\src\crypto\crypto.def -LC:\P ython23\libs -LC:\Python23\PCBuild -llibeay32 -lssleay32 -lWs2_32 -lpython23 -o build\lib.win32-2.3\OpenSSL\crypto.pyd C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin d -llibeay32 collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 Any clues ? Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml From Michael.Foord at tbsmerchants.co.uk Wed Feb 16 16:37:31 2005 From: Michael.Foord at tbsmerchants.co.uk (Michael Foord) Date: Wed, 16 Feb 2005 15:37:31 +0000 Subject: [pyOpenSSL] Building for Windows - Take 2 Message-ID: <421368BB.8060407@tbsmerchants.co.uk> Sorry - resend - I garbled the last message a bit. My apologies. Attempting to build for windows - take 2. If I copy the '.a' and '.def' files to the 'C:\mingw32\lib' directory and the include files to 'C:\mingw32\includes' - I get a very different error message. D:\Downloads\pyOpenSSL-0.6>setup.py build_ext -cmingw32 running build_ext building 'OpenSSL.crypto' extension creating build creating build\temp.win32-2.3 creating build\temp.win32-2.3\Release creating build\temp.win32-2.3\Release\src creating build\temp.win32-2.3\Release\src\crypto C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/crypto.c -o build\temp.win32-2.3\Release\src\crypto\crypto. o src/crypto/crypto.c:20: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkey.c -o build\temp.win32-2.3\Release\src\crypto\pkey.o src/crypto/pkey.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/netscape_spki.c -o build\temp.win32-2.3\Release\src\crypto\ netscape_spki.o src/crypto/netscape_spki.c:12: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509req.c -o build\temp.win32-2.3\Release\src\crypto\x509re q.o src/crypto/x509req.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs12.c -o build\temp.win32-2.3\Release\src\crypto\pkcs12. o src/crypto/pkcs12.c:17: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/util.c -o build\temp.win32-2.3\Release\src\util.o src/util.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509.c -o build\temp.win32-2.3\Release\src\crypto\x509.o src/crypto/x509.c:15: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/pkcs7.c -o build\temp.win32-2.3\Release\src\crypto\pkcs7.o src/crypto/pkcs7.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509store.c -o build\temp.win32-2.3\Release\src\crypto\x509 store.o src/crypto/x509store.c:13: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509ext.c -o build\temp.win32-2.3\Release\src\crypto\x509ex t.o src/crypto/x509ext.c:14: warning: 'CVSid' defined but not used C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python23\include -IC:\Pytho n23\PC -c src/crypto/x509name.c -o build\temp.win32-2.3\Release\src\crypto\x509n ame.o src/crypto/x509name.c:15: warning: 'CVSid' defined but not used writing build\temp.win32-2.3\Release\src\crypto\crypto.def creating build\lib.win32-2.3 creating build\lib.win32-2.3\OpenSSL C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.3\Release\src\cry pto\crypto.o build\temp.win32-2.3\Release\src\crypto\x509.o build\temp.win32-2.3 \Release\src\crypto\x509name.o build\temp.win32-2.3\Release\src\crypto\pkey.o bu ild\temp.win32-2.3\Release\src\crypto\x509store.o build\temp.win32-2.3\Release\s rc\crypto\x509req.o build\temp.win32-2.3\Release\src\crypto\x509ext.o build\temp .win32-2.3\Release\src\crypto\pkcs7.o build\temp.win32-2.3\Release\src\crypto\pk cs12.o build\temp.win32-2.3\Release\src\crypto\netscape_spki.o build\temp.win32- 2.3\Release\src\util.o build\temp.win32-2.3\Release\src\crypto\crypto.def -LC:\P ython23\libs -LC:\Python23\PCBuild -llibeay32 -lssleay32 -lWs2_32 -lpython23 -o build\lib.win32-2.3\OpenSSL\crypto.pyd C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin d -llibeay32 collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 Any clues ? Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml From kototama-code at altern.org Tue Feb 22 23:04:29 2005 From: kototama-code at altern.org (Kototama) Date: Tue, 22 Feb 2005 23:04:29 +0100 Subject: [pyOpenSSL] select + ssl Message-ID: <421BAC6D.8090203@altern.org> Hello, I don't have the same behaviour with two codes who are quite the same, one using SSL, the other not. I tested the programs with stunnel and telnet , respectively. Here are the first code : ------------------------------------------------------------------------------------------------------------------------------------------------ #!/usr/bin/python from select import select import socket if __name__ == '__main__': s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 6001)) s.listen(5) ready_read = {} ready_send = {} ready_read[s] = s while True: rs, ws, _ = select(ready_read.keys(), ready_send.keys(), [], 2) print '.' for r in rs: if r == s: (cli, addr) = s.accept() ready_send[cli] = cli ready_read[cli] = cli else: ret = r.recv(1000) print 'ret =', ret for w in ws: w.send('you have to give up') ------------------------------------------------------------------------------------------------------------------------------------------------ The client receive the 'you have to give up' sentence every two seconds. The second code is : ------------------------------------------------------------------------------------------------------------------------------------------------ #!/usr/bin/python from select import select import socket from OpenSSL import SSL import os def verify_cb(): return ok if __name__ == '__main__': dir = '' ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.set_options(SSL.OP_NO_SSLv2) ctx.set_verify(SSL.VERIFY_NONE, verify_cb) ctx.use_privatekey_file (os.path.join(dir, 'server.pkey')) ctx.use_certificate_file(os.path.join(dir, 'server.cert')) ctx.load_verify_locations(os.path.join(dir, 'CA.cert')) s = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) #s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 6000)) s.listen(5) s.setblocking(0) ready_read = {} ready_send = {} ready_read[s] = s while True: rs, ws, _ = select(ready_read.keys(), ready_send.keys(), [], 2) print '.' for r in rs: if r == s: (cli, addr) = s.accept() ready_send[cli] = cli ready_read[cli] = cli else: ret = r.recv(1000) print 'ret =', ret for w in ws: w.send('you have to give up') ------------------------------------------------------------------------------------------------------------------------------------------------ The server blocks on recv here. In both case I don't send anything with the client. (Perhaps stunnel send something that I don't see ?) Why does the server block ? Kototama