Establishing Https connection

Discussion in 'Python' started by nenad.cikic@gmail.com, Dec 11, 2012.

  1. Guest

    Hello,
    Once I get my xml populated I have to send it to web service.
    Should I use httplib?
    I am reading the docs and I have managed to open the connection with
    httplib.HTTPSConnection(host[, port[, key_file[, cert_file[, strict[, timeout[, source_address]]]]]])
    After that i intend to use
    HTTPConnection.request('POST', url[, body[, headers]])

    During opening it asks me for the password. I see that the urllib class has prompt_user_passwd() that can be overriden for the password supply, so that no console action is necessary, but with httplib how is done?
    My questions are:
    -am I using the right class?
    -i intend to store certificate and private key in database, but how can I use them without saving back to file?

    I have already developed applications for http/https but not in python, so I need some hint to point me in the right direction.

    Thanks
    Nenad
    , Dec 11, 2012
    #1
    1. Advertising

  2. Kwpolska Guest

    On Tue, Dec 11, 2012 at 7:26 PM, <> wrote:
    > Hello,
    > Once I get my xml populated I have to send it to web service.
    > Should I use httplib?
    > I am reading the docs and I have managed to open the connection with
    > httplib.HTTPSConnection(host[, port[, key_file[, cert_file[, strict[, timeout[, source_address]]]]]])
    > After that i intend to use
    > HTTPConnection.request('POST', url[, body[, headers]])
    >
    > During opening it asks me for the password. I see that the urllib class has prompt_user_passwd() that can be overriden for the password supply, so that no console action is necessary, but with httplib how is done?
    > My questions are:
    > -am I using the right class?
    > -i intend to store certificate and private key in database, but how can Iuse them without saving back to file?
    >
    > I have already developed applications for http/https but not in python, so I need some hint to point me in the right direction.
    >
    > Thanks
    > Nenad
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    I, for one, suggest <http://python-requests.org/> for your sanity. I
    guess it would be something along the lines of:

    import requests
    xml = """<?xml version="1.0" encoding="UTF-8" ?> ..."""
    files = {'file-field-as-requested-by-the-service': xml}
    requests.post(url, files=files, auth=HTTPDigestAuth('user', 'pass'))


    Plus http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification
    and other stuff from there.

    Httplib may not be wrong, but I’m doing this for your sanity.
    --
    Kwpolska <http://kwpolska.tk>
    stop html mail | always bottom-post
    www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    GPG KEY: 5EAAEA16
    Kwpolska, Dec 11, 2012
    #2
    1. Advertising

  3. Guest

    Many thanks, I will check it.

    Nenad
    , Dec 12, 2012
    #3
  4. Guest

    Many thanks, I will check it.

    Nenad
    , Dec 12, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chad W. Taylor
    Replies:
    1
    Views:
    2,973
    iksrazal
    Jun 26, 2004
  2. gs
    Replies:
    8
    Views:
    422
    Carl Scharenberg
    Oct 11, 2004
  3. =?Utf-8?B?dGhvbQ==?=

    error while establishing a connection to the server

    =?Utf-8?B?dGhvbQ==?=, Jul 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    12,454
    =?Utf-8?B?dGhvbQ==?=
    Jul 25, 2006
  4. Tor Inge Rislaa
    Replies:
    0
    Views:
    705
    Tor Inge Rislaa
    Sep 27, 2006
  5. gnewsgroup
    Replies:
    0
    Views:
    316
    gnewsgroup
    Jan 2, 2008
Loading...

Share This Page