Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19279 > unrolled thread
| Started by | Adam Mercer <ramercer@gmail.com> |
|---|---|
| First post | 2012-01-23 14:01 -0600 |
| Last post | 2012-01-25 15:40 -0600 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Determining version of OpenSSL linked against python? Adam Mercer <ramercer@gmail.com> - 2012-01-23 14:01 -0600
Re: Determining version of OpenSSL linked against python? Anssi Saari <as@sci.fi> - 2012-01-25 23:21 +0200
Re: Determining version of OpenSSL linked against python? Adam Mercer <ramercer@gmail.com> - 2012-01-25 15:40 -0600
| From | Adam Mercer <ramercer@gmail.com> |
|---|---|
| Date | 2012-01-23 14:01 -0600 |
| Subject | Determining version of OpenSSL linked against python? |
| Message-ID | <mailman.4974.1327348932.27778.python-list@python.org> |
Hi
I'm trying to write a script that determines the version of OpenSSL
that python is linked against, using python-2.7 this is easy as I can
use:
import ssl
ssl.OPENSSL_VERSION
but unfortunately I need to support python-2.6, from an older script I
used the following:
import _ssl
ssl_lib = _ssl.__file__
to get the path to the _ssl.so module and then I parsed the output of
ldd (on linux) to get the path to the OpenSSL library and then parsed
the version from the filename. In other words it's very messy.
I had a little success using this approach but I have recently
received a bug report that this doesn't seem to work on Debian
Squeeze. When I try to query the __file__ attribute of the _ssl module
I get the following error:
>>> import _ssl
>>> _ssl.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'
>>>
Can anyone offer any suggestions as to what is going wrong with the
above code or offer an alternative way of determining the OpenSSl
version using python-2.6?
Cheers
Adam
[toc] | [next] | [standalone]
| From | Anssi Saari <as@sci.fi> |
|---|---|
| Date | 2012-01-25 23:21 +0200 |
| Message-ID | <vg3liovh40v.fsf@sci.fi> |
| In reply to | #19279 |
Adam Mercer <ramercer@gmail.com> writes:
> Can anyone offer any suggestions as to what is going wrong with the
> above code or offer an alternative way of determining the OpenSSl
> version using python-2.6?
I suppose you could use ctypes to load the library and call SSLeay()
which returns the OpenSSL version number as a C long.
Like this:
from ctypes import *
libssl = cdll.LoadLibrary("libssl.so")
openssl_version = libssl.SSLeay()
print "%.9X" % openssl_version
This gives me 0009080FF which corresponds to 0.9.8o release which is
what I have installed in Debian Squeeze.
[toc] | [prev] | [next] | [standalone]
| From | Adam Mercer <ramercer@gmail.com> |
|---|---|
| Date | 2012-01-25 15:40 -0600 |
| Message-ID | <mailman.5096.1327527649.27778.python-list@python.org> |
| In reply to | #19436 |
On Wed, Jan 25, 2012 at 15:21, Anssi Saari <as@sci.fi> wrote:
> I suppose you could use ctypes to load the library and call SSLeay()
> which returns the OpenSSL version number as a C long.
>
> Like this:
>
> from ctypes import *
> libssl = cdll.LoadLibrary("libssl.so")
> openssl_version = libssl.SSLeay()
> print "%.9X" % openssl_version
>
> This gives me 0009080FF which corresponds to 0.9.8o release which is
> what I have installed in Debian Squeeze.
Thanks, that looks useful.
Cheers
Adam
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web