Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give access to openssl version number #52568

Closed
pitrou opened this issue Apr 5, 2010 · 12 comments
Closed

Give access to openssl version number #52568

pitrou opened this issue Apr 5, 2010 · 12 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@pitrou
Copy link
Member

pitrou commented Apr 5, 2010

BPO 8321
Nosy @loewis, @pitrou, @giampaolo, @benjaminp, @florentx
Files
  • sslversion.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-04-05.21:46:20.037>
    created_at = <Date 2010-04-05.20:42:52.504>
    labels = ['type-feature', 'library']
    title = 'Give access to openssl version number'
    updated_at = <Date 2010-04-05.22:56:26.802>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-04-05.22:56:26.802>
    actor = 'giampaolo.rodola'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-04-05.21:46:20.037>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2010-04-05.20:42:52.504>
    creator = 'pitrou'
    dependencies = []
    files = ['16769']
    hgrepos = []
    issue_num = 8321
    keywords = ['patch']
    message_count = 12.0
    messages = ['102406', '102408', '102411', '102413', '102415', '102417', '102418', '102419', '102420', '102421', '102422', '102425']
    nosy_count = 6.0
    nosy_names = ['loewis', 'janssen', 'pitrou', 'giampaolo.rodola', 'benjamin.peterson', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue8321'
    versions = ['Python 2.7', 'Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    This patch gives access to the OpenSSL version the _ssl module is linked against, through three attributes: one gives the raw integer, another the decoded 5-tuple of ints, the last one the version string as returned by OpenSSL.

    @pitrou pitrou added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Apr 5, 2010
    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    (note: tested with OpenSSL 0.9.8k and 1.0.0)

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Apr 5, 2010

    Can you please add documentation as well?

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    New patch with doc.

    @giampaolo
    Copy link
    Contributor

    I was about to open a request for this.
    Thanks.

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    Committed, with Benjamin's permission, in r79812 (trunk) and r79813 (py3k).

    @pitrou pitrou closed this as completed Apr 5, 2010
    @giampaolo
    Copy link
    Contributor

    >>> import ssl
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/ssl.py", line 62, in <module>
        from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
    ImportError: cannot import name OPENSSL_VERSION_NUMBER

    Just in case it's my fault, here's what I've done before importing ssl module:

    svn up
    Updated to revision 79814.
    make distclean
    ...
    ./configure ; make ; make install
    ...

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    > >>> import ssl
    > Traceback (most recent call last):
    >   File "<stdin>", line 1, in <module>
    >   File "/usr/local/lib/python2.7/ssl.py", line 62, in <module>
    >     from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
    > ImportError: cannot import name OPENSSL_VERSION_NUMBER

    This looks rather unlikely.
    Can you type "import _ssl" and then check _ssl.__file__ to see if it's
    the one that's just been compiled?
    Or did compilation fail?

    @giampaolo
    Copy link
    Contributor

    The ./configure -> make -> make install process went fine, or at least, I think so, as it completed without reporting errors or exiting.
    ...But maybe I'm doing something wrong as just a little while ago I was modifying _ssl.c but wasn't able to see those changes applied.

    So I'm gonna ask: when I modify *.c files, do I have to do something else other than "./configure; make; make install" in order to see the changes applied?

    Anyway, here's what you asked:

    root@ubuntu:/home/giampaolo/svn/python-2.7# python
    Python 2.7a4+ (trunk:79814, Apr  5 2010, 23:53:01) 
    [GCC 4.4.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import _ssl
    >>> _ssl
    <module '_ssl' from '/usr/local/lib/python2.7/lib-dynload/_ssl.so'>
    >>> _ssl.__file__
    '/usr/local/lib/python2.7/lib-dynload/_ssl.so'
    >>>

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    So I'm gonna ask: when I modify *.c files, do I have to do something
    else other than "./configure; make; make install" in order to see the
    changes applied?

    No.

    If you run the Python binary from the SVN checkout directory (rather
    than from an installation), _ssl should come from the build
    subdirectory, not from /usr/local/lib.
    Example here:

    $ pwd
    /home/antoine/cpython/newssl
    $ ./python -c "import _ssl; print _ssl.__file__"
    /home/antoine/cpython/newssl/build/lib.linux-x86_64-2.7/_ssl.so

    If _ssl is coming from "/usr/local/lib/...", it means that something
    modifies your sys.path so as to put that path before the path to the
    just built extension modules. I can't really investigate this point for
    you, but try using "python -E" instead.

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2010

    So I'm gonna ask: when I modify *.c files, do I have to do something
    else other than "./configure; make; make install" in order to see the
    changes applied?

    Oh, sorry, I had overlooked the "make install" bit.
    Well then I don't know. But you can run the interpreter without
    installing :-) (just "./python")

    And check the output of "make" after you have touched Modules/_ssl.c

    @giampaolo
    Copy link
    Contributor

    You were right: make output had an error involving ssl I didn't notice. My bad.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants