HTTPS won't work, no matter which lib and how.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phillip

    HTTPS won't work, no matter which lib and how.

    Hi.
    I'm having some anoying trouble trying to establish a https connection.
    I've even switched Python Versions (from 2.2.3 to 2.3.3), but the Errors
    remain basically the same, allthough they now come in nice XML :-).

    Here are some examples:

    My last desperate try (which is way off the book):[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]
    import re
    import base64
    import httplib
    import urllib2
    import string
    # don't know if I need this one, it doesn't fix anything it seems...
    import socket

    suffix = r"blah"
    prefix = r"jada"

    basicAuth = base64.encodest ring(prefix + r":" + suffix)

    kopf = {"Basic": basicAuth}

    req = urllib2.Request (url="https://myurl/", data="", headers = kopf)
    fileLines = urllib2.https_o pen(req)
    print "Recieved:"
    print fileLines
    <<<
    This is the Error it throws:
    ./gethttps.py
    Traceback (most recent call last):
    File "./gethttps.py", line 30, in ?
    fileLines = urllib2.https_o pen(req)
    AttributeError: 'module' object has no attribute 'https_open'


    The obvious one doesn't work either ALTHOUGH it's an Example from the
    official urllib2 docs!!!:[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]
    import re
    import base64
    import httplib
    import urllib2
    import string
    import socket

    suffix = r"blah"
    prefix = r"jada"

    basicAuth = base64.encodest ring(prefix + r":" + suffix)

    kopf = {"Basic": basicAuth}

    req = urllib2.Request (url="https://myurl/", data="", headers = kopf)

    fileLines = urllib2.urlopen (req)

    print "Recieved:"
    print fileLines
    <<<
    Here are the Errors throwed:
    Traceback (most recent call last):
    File "./gethttps.py", line 25, in ?
    fileLines = urllib2.urlopen (req)
    File "/usr/local/lib/python2.3/urllib2.py", line 129, in urlopen
    return _opener.open(ur l, data)
    File "/usr/local/lib/python2.3/urllib2.py", line 331, in open
    'unknown_open', req)
    File "/usr/local/lib/python2.3/urllib2.py", line 306, in _call_chain
    result = func(*args)
    File "/usr/local/lib/python2.3/urllib2.py", line 914, in unknown_open
    raise URLError('unkno wn url type: %s' % type)
    urllib2.URLErro r: <urlopen error unknown url type: https>



    Does anybody have any Idea how I can open a https connection using
    Python? The http, urllib and urllib2 in a whole seem quite a messy bunch
    and I have had no success so far trying to grasp how to handle large
    parts of them.
    There are traces on the web saying that some socket stuff needs ssl
    compiled into them in order for https stuff to work, but they seem old
    and since I'm using the fresh original sources from www.python.org on a
    Debian Linux system I presume that compiling should work A-OK.
    If anybody thinks this is likeley to be a compiling issue, how and where
    do I change the original source distribution to support https? In some
    make or configure file maybe? I have no Idea. How do I find out if ssl
    is supported in my install?
    I'd be glad if someone could help, this all is driving me nuts.

    Thanks.

    Phillip

    BTW: Since there is apsolutely no documentation on how to use the larger
    part of urllib2's stuff on python.org it would be nice if someone could
    also point out a howto or some working examples of how and in which
    situations to use these classes and methods, such as OpenerDirector( ???)
    and such.
  • Lee Harr

    #2
    Re: HTTPS won't work, no matter which lib and how.

    On 2004-05-17, Phillip <forget-it@no-spam.com> wrote:[color=blue]
    > Hi.
    > I'm having some anoying trouble trying to establish a https connection.
    > I've even switched Python Versions (from 2.2.3 to 2.3.3), but the Errors
    > remain basically the same, allthough they now come in nice XML :-).
    >[/color]


    Maybe this will help...



    Comment

    Working...