More M2Crypto issues

Gabriel Genellina gagsl-py at
Thu Jan 18 21:29:07 EST 2007

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/", line 46, in ?
>      DetailsPageBuilder.detailspage(kdbfile,ktemplatefile,url)  # check and
>display domain or URL as web page
>    File "./sitetruth/", line 70, in detailspage
>      sitecert = InfoSSL2.Certificate(siteinfo, kverifylocations, verbose)
>    File "./sitetruth/", line 147, in __init__
>      self.ctx = createsslcontext(trustedcafile, verbose)        # 
> Generate general SSL
>    File "./sitetruth/", line 40, in createsslcontext
>      ctx = 
> SSL.Context('sslv3') 
>   # Create context with SSL params
>    File "/home/sitetruth/lib/python/M2Crypto/SSL/", 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_SSL_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! 

More information about the Python-list mailing list