×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    10

    Question httplib.HTTPSConnection with X.509 Key & Cert

    Hi,

    I'm trying to do a HTTPSConnection to a server using a key and certificate:

    Code:
    import httplib
    import sys
    
    try:
        connection = httplib.HTTPSConnection(host, 443, key_file, cert_file)
        connection.request('GET', path)
        response = connection.getresponse()
        print response.status, response.reason
    except:
        print sys.exc_type, sys.exc_value
    connection.close()
    When I try and run this I get the mesage:

    'socket.error Unsupported feature' from the request() call. I can, however, make the HTTPS request without the key and certificate.

    Looking through the source for httplib.py and socket.py I can't seem to find why this is unsupported.

    Can anyone tell me if this can be done? (or what I'm doing wrong?)

    Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    7
    I can't help but I've been trying to get an SSL connection to work on at all without any luck. If the site uses an untrusted cert then it pops up with the dialog asking me whether I want to continue and then just exits the Python app. Not good.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    10
    Originally posted by layzee
    ...I've been trying to get an SSL connection to work without any luck.
    Are you trying a straight SSL connection (using a socket) or via a HTTPS ?

    I had no problems getting an HTTPS (HTTP/SSL) connection without certificates, but the code with certificates doesn't work for me.

    (I require client authentication server-side, hence me wanting to use a client certificate).

    Thanks,

    M.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    7
    Yeah not using a cert like you something like this:

    Code:
    import urllib
    opener = urllib.URLopener()
    g = opener.open("https://www.thawte.com/")
    print g.read(20)
    g.close()
    This works fine on Python on my deskop (WinXP) but not on the phone. It creates a connection - prompts to use GPRS connection profile, and obviously checks the cert (pops up the untursted cert dialog if the root certs aren't installed) and then just exits Python.

    If you could post some working code that'd be great.

  5. #5
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643
    Originally posted by lvngt5gj9
    Are you trying a straight SSL connection (using a socket) or via a HTTPS ?

    I had no problems getting an HTTPS (HTTP/SSL) connection without certificates, but the code with certificates doesn't work for me.

    (I require client authentication server-side, hence me wanting to use a client certificate).

    Thanks,

    M.
    Unfortunately client certificates are not supported by the current socket module.

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    10
    Originally posted by jplauril
    Unfortunately client certificates are not supported by the current socket module.
    Thanks for the information. At least I know it wasn't anything I was doing.

    Do you know if there any plans to add such supprt in future releases?

    (Shall I add it to the wish list?)

    Thanks,

    M.

  7. #7
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643
    FYI: there is a bug (#207) in current SSL support. See this thread:

    http://discussion.forum.nokia.com/fo...threadid=55760

  8. #8
    Registered User
    Join Date
    May 2005
    Posts
    10
    Thanks, I'm looking forward to using https when its fixed!

    M.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •