checking invalid urls with ssl + python 2.1.3 on linux/windows

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

    checking invalid urls with ssl + python 2.1.3 on linux/windows

    Hi,

    I'm trying to do a simple link checking for python 2.1.3 (compiled from
    source on linux), but it fails when I use an invalid ssl url. For
    example: I have zope without ssl running on port 8080, if I do this on
    the browser's address bar:

    https://my_ip:8080 --> The https is intentional

    mozilla on linux and IE on windows, take a long time till a timeout
    occurs. I tried to check this timeout with the timeoutsocket.p y (version
    1.23, the latest I could find) on linux, but it hangs:

    import timeoutsocket
    import smtplib
    import urllib2

    timeoutsocket.s etDefaultSocket Timeout(5)
    urllib2.urlopen ('https://my_ip:8080')

    Same happens with:

    import httplib
    import timeoutsocket
    import smtplib

    timeoutsocket.s etDefaultSocket Timeout(5)
    connection=http lib.HTTPSConnec tion('my_ip:808 0')
    connection.requ est('GET','/')

    I searched on the newsgrous and found that timeoutsocket doesn't work
    with ssl sockets. So, I tried with signal alarms and the httplib and it
    succeeded on linux, but it doesn't work on windows because this os lacks
    of "signal.SIGALRM " :-(. I now about "socket.setdefa ulttimeout", but
    this is a new feature and it doesn't exist on python 2.1.3 and I have to
    provide compatibility to this version (zope 2.6.x uses it).

    Finally I found a message from Geoffrey Talvola, where he said that he
    has a patch which corrects this, but unfortunatelly I tried to contact
    him without any success. Does any body has such patch or perhaps a
    better idea of how to solve this problem?

    Regards,
    Josef
  • Josef Meile

    #2
    Re: checking invalid urls with ssl + python 2.1.3 on linux/windows

    Josef Meile wrote:[color=blue]
    >
    > [snip]
    >
    > I searched on the newsgrous and found that timeoutsocket doesn't work
    > with ssl sockets. So, I tried with signal alarms and the httplib and it
    > succeeded on linux, but it doesn't work on windows because this os lacks
    > of "signal.SIGALRM " :-(. I now about "socket.setdefa ulttimeout", but
    > this is a new feature and it doesn't exist on python 2.1.3 and I have to
    > provide compatibility to this version (zope 2.6.x uses it).[/color]

    I gave up, I tried everything from timeoutsocket till threads, but it
    always hangs. Even with threads, it doesn't matter if they are set as
    daemons, the main thread will wait till the child threads are finished,
    thing that doesn't happen, so it just hangs. I search several
    alternatives and found that it is not a timeoutsocket problem. It seems
    to be a bug on the ssl sockets of 2.1.3. So, I guess I will have to
    avoid https url checking with this old python.

    Regards,
    Josef

    Comment

    Working...