curl-and-python

SSL error

From: Cem Kozinoglu <ckozinoglu_at_yahoo.com>
Date: Wed, 18 Jun 2008 13:47:28 -0700 (PDT)

Hi Guys,

I am trying to write a simple code to extract some headers on an SSL page, PHP version works fine, Python version suffers from an error:

Error : <class 'pycurl.error'> (35, 'Unknown SSL protocol error in connection to atlasweb.etstur.com:443 ')
(35, 'Unknown SSL protocol error in connection to atlasweb.etstur.com:443 ')

Python V2.5.2

Curl:
curl 7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: IDN IPv6 Largefile NTLM SSL libz

Pycurl: latest

Here is the code:

####################################
import sys
import pycurl

url = 'https://atlasweb.etstur.com/WebAir/webAir/processWebLogin.do?referrer=&language=TR&airFrom=ESB&airWhere=IST&airDepartureDate=31/01/2008&airDepartureClass=Hepsi&airReturnDate=31/01/2008&airTransportType=0&airAdultCount=1&airBabyCount=0&airChildCount=0&airOgrCount=0&airTskCount=0'

method = 'get'
ssl = True
referer = ''
useragent = ''
data = ''

def body_callback(buf):
  body = body + buf

c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(c.WRITEFUNCTION, body_callback)

c.setopt(pycurl.FOLLOWLOCATION, 1)

if ssl:
  c.setopt(pycurl.SSL_VERIFYPEER, false)
  c.setopt(pycurl.SSL_VERIFYHOST, false)

c.setopt(pycurl.USERAGENT, useragent)
c.setopt(pycurl.REFERER, referer)

c.setopt(pycurl.HEADER, 1)

if method == 'post':
   c.setopt(pycurl.POSTFIELDS, postdata)
try:
  page = c.perform()
except Exception, e:
  exctype, excvalue = sys.exc_info()[:2]
  if excvalue == None:
     excvalue = ''
  errmsg = "Error : %s %s" % (exctype, excvalue)
  print errmsg
  print e

c.close()

########################################

      

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2008-06-18