I need to implement a save HTTPS-connection to a server.
Does anyone can give an excample on how to establish a HTTPS-connection? I found this posting from madsbjoern which does not sound very optimistic.
Is https working at all on pys60?
I need to implement a save HTTPS-connection to a server.
Does anyone can give an excample on how to establish a HTTPS-connection? I found this posting from madsbjoern which does not sound very optimistic.
Is https working at all on pys60?
hi novis
check at this page
hope this helps you.
give a feedback
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
Hi gaba88,
thx for replying. The excample on the side is for HTTP. I use HTTP-connections to download files for a while now without any problems.
At the current state I plan to implement the same in HTTPS.
I'd like to test an HTTPS-connection now and was a bit "shocked" to find no one in the forum who was successful on using HTTPS-connections
This was the reason for my question if HTTPS is working at all in pys60.
cheers
novis
hi novis
sorry as i didnt got your question.
you point is a absolutely correct and has got a valid point. did u used HTTPS and if tried were you successful or what error did you got.
plz give a feedback
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
@gaba88
I did not try it so far.
@all
can someone pls. confirm that the use of HTTPS is working in a proper way or that it is not working.
If yes, can someone provide a working (tested) example?
cheers
novis
hi novis again
i used HTTPS in my code and i dosent worked for me gave two different types of error.![]()
its better you also check it.
thanks
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
There is a class called HTTSConnection, so in theory it should work. Please note, that class HTTPResponse debuglevel is by default 0. You should set it "higher" manually.
Btw you didn't mention which S60 version you're using, things ARE different for 2nd and 3rd edition devices:
...in general: debug your code by trapping exceptions, writing useful strings into log file or use trace/profile.# On S60 3rd Ed secure sockets must be given the expected
# hostname before connecting or error -7547 occurs. This
# is not needed on 2nd edition. See known issue KIS000322.
Cheers,
--jouni
hi jouni
why the HTTPSconnection is not working in my case and giving errors but at the same function HTTP is working fine.
waitin for your feedback.
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
What kind of errors? They sometimes contain useful info, unlile the generic System Error -50
It's not enought to change from HTTPConnection to HTTPSConnection, there are additional arguments:Code:SSL_ERROR_NONE=0 SSL_ERROR_SSL=1 SSL_ERROR_WANT_READ=2 SSL_ERROR_WANT_WRITE=3 SSL_ERROR_WANT_X509_LOOKUP=4 SSL_ERROR_SYSCALL=5 SSL_ERROR_ZERO_RETURN=6 SSL_ERROR_WANT_CONNECT=7 SSL_ERROR_EOF=8 SSL_ERROR_INVALID_ERROR_CODE=9
...then there's the possibility that HTTPS might be buggy or not fully implemented. I have never tried it, so I'm walking on thin ice.Code:class HTTPConnection: def __init__(self, host, port=None, strict=None, hostname=None): class HTTPSConnection(HTTPConnection): def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None, hostname=None):
--jouni
https works fine for me
if you try to connect to an ip instead of hostname you will
need to send httpsconnection argument of hostname='bla.com' for example.
you just send it anyway aswell since it doesnt matter what hostname it will get works for me anyway
@roidayan
thx for replying,
you seem to have some experience on using https-connections already.
Could you please give a code example on how you connect to an host with https?
many thx
novis
sure
example1:
conn = httplib.HTTPSConnection("www.hostname.com")
conn.request("POST", "/login", params, headers)
example2:
conn = httplib.HTTPSConnection("xxx.xxx.xxx.xxx",hostname='bla.com')
conn.request("POST", "/login", params, headers)
ofcurse xxx.xxx.xxx.xxx is the ip you try to connect to.
hostname should be the hostname of where you try to connect
but i use bla.com for everywhere it works fine![]()
@roidayan
thx man.
In my case I need to download a picture. I asume I'll need a GET instead of a POST.
I'll try as soon as I can.
cheers
novis
hi roidyan
thanks for the solution i also got my HTTPS connection working.
thanks
Gargi Das- http://gargidas.blogsot.com
Forum Nokia Python Wiki
Learn Python at http://mobapps.org/PyS60
Can you show a little bit of code from your application?
I don't know why, but I get an ACCESS_DENIED error all the time, and I would like to check how to add certificates to my queries, so the server does not complain. I guess that's my problem.
Here comes my query:
headers = {"Content-type": "application/html+xml","Accept": "text/plain"}
conn = httplib.HTTPSConnection(servername2.text)
conn.request("GET", serverpath2.text, '', headers)
response2 = conn.getresponse()
resp = response2.read()
print resp
servername2.text is my servername "didacgil.mymobilesite.net"
serverpath2.text is the path "database/convert_to_XML.php"
and the result should be an XML file that I can perfectly get when I query http://127.0.0.1/database/convert_to_XML.php, and I can perfectly parse.
As you can imagine, I need HTTPS as if I want to get information from another PyS60, I will go through Nokia Gateway from Mobile Web Server.
Thank you very much, I'm still learning![]()