Interfacing to the LinkPoint API with Python - Sending XML Over SSH with Authentication
===

I'm trying to make a successful connection to the LinkPoint gateway using Python.  For those of you unfamiliar with their API you get a `.pem` file you use for authentication purposes.

I'm having trouble using this file and creating a secure connection over SSL.

According to their API documentation (which leaves a lot to be desired, btw) I believe the configuration should look similar to below:

    HOST = 'secure.linkpt.net'
    API_URL = 'https://secure.linkpt.net/lpc/servlet/lppay'
    PORT = 1179
    cert_key = my_cert_key.pem

Using this information and a valid `XML` string how can I create this connection?

I'm pretty new to `HTTP` connections in Python.  I've successfully implemented connections with other APIs using a `POST` with `urllib2`.  Naturally, my first attempt started with a similar approach hoping I could stumble on to a solution.

Something like:

    headers = { 'User-Agent'     : 'Rico',
                'Content-type'   : 'text/xml; charset=\"UTF-8\"',
                'Content-length' : len(self.xml_string),
              }
    
    # POST to First Data (Link Point)
    req = urllib2.Request(API_URL, self.xml_string, headers)
    response = urllib2.urlopen(req)
    self.handleResponse(response.read())

I had little hopes this would work as I didn't provide anything about the `cert_key` or the `PORT`.

After this attempt I tried to use a similar approach as I found from a solution from another [stackoverflow][1] post.  Unfortunately I wasn't able to get far with this as I don't have `ca_certs` or `cert` files (that I know of).

I've tried to use [Requests][2] but can't find the documentation/examples for me to make sense of it.

I've also tried to use [Twisted][3], and I really hoped I could do something with this but this feels like trying to open a door with a wrecking ball.  It just feels like overkill to me.  I just need a simple connection/request/response...this seems overly complicated for that.

My next attempt was going to be [PycURL][4], but have confronted enough despair during this process I thought I'd come here to see if someone had some good suggestions before diving into this.

If you think I should re-visit one of these tools please let me know.  I didn't spend a great deal of time with any of these - just enough to get my feet wet.  If you could also point me to a good example or detailed documentation that would be fantastic.

Also, I'd prefer not to use the standard `SSL` library to build the connection myself - I don't want to reinvent the wheel if I don't have to.


  [1]: http://stackoverflow.com/questions/9093289/how-to-create-a-dual-authentication-https-client-in-python-without-lgpl-libs
  [2]: http://docs.python-requests.org/en/latest/index.html
  [3]: http://twistedmatrix.com/trac/
  [4]: http://pycurl.sourceforge.net/