473,834 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

More M2Crypto issues

I've been running M2Crypto successfully using Python 2.4 on Windows 2000,
and now I'm trying to get it to work on Python 2.3.4 on Linux.

Attempting to initialize a context results in

Traceback (most recent call last):
File "/www/htdocs/sitetruth.com/cgi/ratingdetails.c gi", line 46, in ?
DetailsPageBuil der.detailspage (kdbfile,ktempl atefile,url) # check and
display domain or URL as web page
File "./sitetruth/DetailsPageBuil der.py", line 70, in detailspage
sitecert = InfoSSL2.Certif icate(siteinfo, kverifylocation s, verbose)
File "./sitetruth/InfoSSL2.py", line 147, in __init__
self.ctx = createsslcontex t(trustedcafile , verbose) # Generate general SSL
context
File "./sitetruth/InfoSSL2.py", line 40, in createsslcontex t
ctx = SSL.Context('ss lv3') # Create context with SSL params
File "/home/sitetruth/lib/python/M2Crypto/SSL/Context.py", line 43, in __init__
map()[long(self.ctx)] = self
ValueError: invalid literal for long(): _480e1008_p_SSL _CTX

which, when I look at the code and try some test cases, seems
legitimate. The cacheing code is trying to convert a reference to an
object (a C object, in fact) into a "long". Python 2.4 on Windows
will do that. Python 2.3.4 on Linux converts it to a string first,
gets "_480e1008_p_SS L_CTX", and then tries to convert that to an
integer, which fails.

M2Crypto is supposed to work with Python 2.3, so this should work.

John Nagle
Jan 18 '07 #1
8 2985
Upgraded to Python 2.5 on the Linux system, rebuild M2Crypto,
and it stil fails, but the last line of the error message changed to:

ValueError: invalid literal for long() with base 10: '_40f91a08_p_SS L_CTX'

Others have encountered this problem, from a Google search.

Is "long" supposed to operate on C objects?

John Nagle

John Nagle wrote:
I've been running M2Crypto successfully using Python 2.4 on Windows 2000,
and now I'm trying to get it to work on Python 2.3.4 on Linux.

Attempting to initialize a context results in

Traceback (most recent call last):
File "/www/htdocs/sitetruth.com/cgi/ratingdetails.c gi", line 46, in ?
DetailsPageBuil der.detailspage (kdbfile,ktempl atefile,url) # check
and display domain or URL as web page
File "./sitetruth/DetailsPageBuil der.py", line 70, in detailspage
sitecert = InfoSSL2.Certif icate(siteinfo, kverifylocation s, verbose)
File "./sitetruth/InfoSSL2.py", line 147, in __init__
self.ctx = createsslcontex t(trustedcafile , verbose) # Generate
general SSL context
File "./sitetruth/InfoSSL2.py", line 40, in createsslcontex t
ctx = SSL.Context('ss lv3') # Create
context with SSL params
File "/home/sitetruth/lib/python/M2Crypto/SSL/Context.py", line 43, in
__init__
map()[long(self.ctx)] = self
ValueError: invalid literal for long(): _480e1008_p_SSL _CTX

which, when I look at the code and try some test cases, seems
legitimate. The cacheing code is trying to convert a reference to an
object (a C object, in fact) into a "long". Python 2.4 on Windows
will do that. Python 2.3.4 on Linux converts it to a string first,
gets "_480e1008_p_SS L_CTX", and then tries to convert that to an
integer, which fails.

M2Crypto is supposed to work with Python 2.3, so this should work.

John Nagle
Jan 18 '07 #2
At Thursday 18/1/2007 04:41, John Nagle wrote:
I've been running M2Crypto successfully using Python 2.4 on Windows 2000,
and now I'm trying to get it to work on Python 2.3.4 on Linux.

Attempting to initialize a context results in

Traceback (most recent call last):
File "/www/htdocs/sitetruth.com/cgi/ratingdetails.c gi", line 46, in ?
DetailsPageBuil der.detailspage (kdbfile,ktempl atefile,url) # check and
display domain or URL as web page
File "./sitetruth/DetailsPageBuil der.py", line 70, in detailspage
sitecert = InfoSSL2.Certif icate(siteinfo, kverifylocation s, verbose)
File "./sitetruth/InfoSSL2.py", line 147, in __init__
self.ctx = createsslcontex t(trustedcafile , verbose) #
Generate general SSL
context
File "./sitetruth/InfoSSL2.py", line 40, in createsslcontex t
ctx =
SSL.Context('ss lv3')
# Create context with SSL params
File "/home/sitetruth/lib/python/M2Crypto/SSL/Context.py", line
43, in __init__
map()[long(self.ctx)] = self
ValueError: invalid literal for long(): _480e1008_p_SSL _CTX
On a previous version of M2Crypto that line said: map()[self.ctx] =
self, and that failed too ("unhashable object", I think).
I changed the class _ctxmap (the map() above returns an instance of
it) to use str(key) in the 3 places it was used. (That would be
equivalent to use str(self.ctx) everywhere, instead of long(self.ctx)
as your traceback is showing). All I can say is that no error
happened afterwards, but I don't know if that broke something. (and I
didn't care at the moment, I only needed a Zope instance running on
Windows with SSL for less than a week - and if it were "cheating SSL"
it was OK for me then)
which, when I look at the code and try some test cases, seems
legitimate. The cacheing code is trying to convert a reference to an
object (a C object, in fact) into a "long". Python 2.4 on Windows
will do that. Python 2.3.4 on Linux converts it to a string first,
gets "_480e1008_p_SS L_CTX", and then tries to convert that to an
integer, which fails.
So using str() appears, at least on the surface, to be reasonable.
But someone with more intimate knowledge of the library should
confirm that. I don't even understand what's the point for the
_ctxmap singleton - it's the same thing as a global dictionary, isn't it?
--
Gabriel Genellina
Softlab SRL


_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 19 '07 #3
Gabriel Genellina wrote:
At Thursday 18/1/2007 04:41, John Nagle wrote:
On a previous version of M2Crypto that line said: map()[self.ctx] =
self, and that failed too ("unhashable object", I think).
I changed the class _ctxmap (the map() above returns an instance of it)
to use str(key) in the 3 places it was used. (That would be equivalent
to use str(self.ctx) everywhere, instead of long(self.ctx) as your
traceback is showing). All I can say is that no error happened
afterwards, but I don't know if that broke something.
So using str() appears, at least on the surface, to be reasonable. But
someone with more intimate knowledge of the library should confirm that.
I don't even understand what's the point for the _ctxmap singleton -
it's the same thing as a global dictionary, isn't it?
I played around with using "str" too, but I was worried about
Python and SWIG version issues. I'm not sure you can use "str"
on those objects on all versions and platforms. I think that
SWIG is generating the implementations of __str__ and __long__.

Incidentally, note in that area that if you never explicitly
call "close" on a Context, it will never be released. Or so
it looks from the code.

Actually, at the moment I'm having an M2Crypto problem related
to a SWIG/OpenSSL conflict. Older versions of OpenSSL have an
include file that needs __i386__ defined, which is something GCC
does based on what platform you're on. SWIG uses CPP, but
doesn't set the platform defines, so the SWIG phase of the
M2Crypto build fails. I'm currently trying to get the shared
host where that build took place upgraded to a later version of
OpenSSL, but that requires a server restart, so it may take
a few days. I'm doing something that requires M2Crypto to
run on a range of machines, which turns out to be rather harder
than expected.

All this stuff is in the area that Guido was unhappy about
in his "M2Crypto Woes" article.

http://www.artima.com/weblogs/viewpost.jsp?thread=95863

The worst problems there have been fixed, but we're not out
of the woods yet. As Guido wrote, using SWIG does complicate
things.

I'm currently getting good results on Windows 2000 with
Python 2.4 using M2Crypto 0.17; right now, the problems are
on the Linux side.

John Nagle
Jan 19 '07 #4
John Nagle wrote:
I've been running M2Crypto successfully using Python 2.4 on Windows 2000,
and now I'm trying to get it to work on Python 2.3.4 on Linux.

Attempting to initialize a context results in

Traceback (most recent call last):
[...]
map()[long(self.ctx)] = self
ValueError: invalid literal for long(): _480e1008_p_SSL _CTX
This is almost certainly because of SWIG that is too old. The minimum
required is SWIG 1.3.24. If you cannot upgrade SWIG, the alternative
would be to play around with these values to fit your version of SWIG.

I'm adding this to the FAQ.

--
Heikki Toivonen
Jan 19 '07 #5
John Nagle wrote:
Actually, at the moment I'm having an M2Crypto problem related
to a SWIG/OpenSSL conflict. Older versions of OpenSSL have an
include file that needs __i386__ defined, which is something GCC
does based on what platform you're on. SWIG uses CPP, but
doesn't set the platform defines, so the SWIG phase of the
M2Crypto build fails. I'm currently trying to get the shared
host where that build took place upgraded to a later version of
OpenSSL, but that requires a server restart, so it may take
a few days. I'm doing something that requires M2Crypto to
run on a range of machines, which turns out to be rather harder
than expected.
Which version of OpenSSL is that?

--
Heikki Toivonen
Jan 19 '07 #6
Heikki Toivonen wrote:
John Nagle wrote:
> Actually, at the moment I'm having an M2Crypto problem related
to a SWIG/OpenSSL conflict. Older versions of OpenSSL have an
include file that needs __i386__ defined, which is something GCC
does based on what platform you're on. SWIG uses CPP, but
doesn't set the platform defines, so the SWIG phase of the
M2Crypto build fails. I'm currently trying to get the shared
host where that build took place upgraded to a later version of
OpenSSL, but that requires a server restart, so it may take
a few days. I'm doing something that requires M2Crypto to
run on a range of machines, which turns out to be rather harder
than expected.


Which version of OpenSSL is that?
M2Crypto 0.17 requirements:
Python 2.3 or newer
o m2urllib2 requires Python 2.4 or newer
OpenSSL 0.9.7 or newer
o Some optional new features will require OpenSSL 0.9.8 or newer
SWIG 1.3.24 or newer

Server in use:
Python version: "Python 2.5 (r25:51908, Jan 18 2007, 10:46:37)"
OpenSSL version: "OpenSSL 0.9.7a Feb 19 2003"
SWIG version: "SWIG Version 1.3.31"
GCC version: "[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2"
Computer: Athlon 686 rackmount server.

The actual build failure is:

running build_ext
building 'M2Crypto.__m2c rypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap. c
swig -python -I/usr/include -o SWIG/_m2crypto_wrap. c SWIG/_m2crypto.i
/usr/include/openssl/opensslconf.h:2 7: Error: CPP #error ""This openssl-devel
package does not work your architecture?"" . Use the -cpperraswarn option to
continue swig processing.
error: command 'swig' failed with exit status 1

The problem is that "opensslcon f.h" expects the compiler to define __i386__
when running the C preprocessor, and SWIG doesn't do that. Compare
"opensslcon f.h" in different versions of OpenSSL; it's changed considerably.

John Nagle
Jan 20 '07 #7
John Nagle wrote:
OpenSSL version: "OpenSSL 0.9.7a Feb 19 2003"
Hmm, I've never actually used that old OpenSSL myself, just assumed from
the original author's notes that anything from 0.9.7 onward worked.
Guess not. I am thinking of changing the requirements to state which one
works... I think the oldest that I have personally tested may have been
0.9.7d.

--
Heikki Toivonen
Jan 20 '07 #8
Heikki Toivonen wrote:
John Nagle wrote:
> OpenSSL version: "OpenSSL 0.9.7a Feb 19 2003"


Hmm, I've never actually used that old OpenSSL myself, just assumed from
the original author's notes that anything from 0.9.7 onward worked.
Guess not. I am thinking of changing the requirements to state which one
works... I think the oldest that I have personally tested may have been
0.9.7d.
I think older versions were built with an older OpenSSL and an older
SWIG. The SWIG preprocessor has some limitations which can cause
errors to be reported during the SWIG preprocessor phase.

This problem in SWIG has hit other projects. See

http://blog.gmane.org/gmane.comp.pro...month=20051201

where the Common LISP people had a similar problem.

John Nagle
Jan 20 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7190
by: Carl Waldbieser | last post by:
I tried to adapt the instructions for building the M2Crypto module (http://sandbox.rulemaker.net/ngps/m2/INSTALL.html) to build a version compatible with Python2.3, but I've had some mixed results. I actually got everything to build and install, but when I try to import M2Crypto-- well, here is a sample session: >>> import M2Crypto Traceback (most recent call last): File "<interactive input>", line 1, in ? File...
5
2273
by: jsmilan | last post by:
Hi, all; I'm strictly an amateur developer who has dabbled in a half dozen languages on eight or nine systems over 20 years or so. I have never devoted the time or energy to thoroughly learn any one of them, so I have become a true JOATAMON (Jack Of All Trades And Master Of None). I apologize in advance for any truly newb sounding questions. I did Google for this in several places first (Zope.org, Gentoo forums, and Google UseNet...
1
1819
by: morphex | last post by:
Hi, I get the following messages running the testall.py script with m2crypto 0.13, can anyone tell me what's wrong? .................................................................EEEEEE ====================================================================== ERROR: test_cipher_mismatch (test_ssl.SSLClientTestCase) ---------------------------------------------------------------------- Traceback (most recent call last):
8
3290
by: John Nagle | last post by:
Here's a wierd problem: I have a little test case for M2Crypto, which just opens up SSL connections to web servers and reads their certificates. This works fine. But if I execute socket.setdefaulttimeout(5.0) so that the sockets don't wait too long if there's no SSL server, I get
2
1904
by: John Nagle | last post by:
A list of small problems and bugs in the current M2Crypto: I need to look at SSL certificates in some detail, so this is all about the access functions for certificates. Bugs: 1. Off by one error at "X509.get_ext_count()". Reports eight extensions on a certificate that only has seven. get_ext_at works for extensions 0..6, then returns an undefined for the nonexistent #7.
2
5160
by: John Nagle | last post by:
Trying to build M2Crypto on a dedicated server running Red Hat Fedora Core 6. I'm trying to do this right, without manual patching. The error message I'm getting during build is: python setup.py build .... swig -python -I/usr/include -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i /usr/include/openssl/opensslconf.h:27: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to
10
3597
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1. File "D:\Python24\lib\socket.py", line 295, in read data = self._sock.recv(recv_size) timeout: timed out
5
7709
by: John Nagle | last post by:
I thought I had all the timeout problems with urllib worked around, but no. socket.setdefaulttimeout is useful, but not always effective. I'm setting that to 15 seconds. If the host end won't open the connection within 15 seconds, urllib times out. But if the host end opens the connection, then never sends anything, urllib waits for many minutes before timing out. Any idea how to deal with this? And don't just say "use urllib2"...
7
4246
by: John Nagle | last post by:
Back in March, I posted this: That was for M2Crypto 0.17. It's still broken in M2Crypto 0.18. And there's no RPM or Windows binary. Nobody actually uses this stuff, do they?
0
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9646
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10793
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10510
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7758
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.