473,748 Members | 8,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SSL (HTTPS) with 2.4

Hi all.

Some time ago (years) I had a script on Python 2.2 that would retieve a
HTTPS web site. I used python22-win32-ssl.zip to handle the SSL aspect
and it worked wonderfully. I am revisiting the project and need to
update it to Python 2.4.1. python22-win32-ssl.zip isn't compatable
(duh) and I can't find a newer version. I have had a search and can't
find anything to point me in the right direction.

Can someone please help?

Jul 19 '05 #1
22 6170
Bloke wrote:
Some time ago (years) I had a script on Python 2.2 that would retieve a
HTTPS web site. I used python22-win32-ssl.zip to handle the SSL aspect
and it worked wonderfully. I am revisiting the project and need to
update it to Python 2.4.1. python22-win32-ssl.zip isn't compatable
(duh) and I can't find a newer version. I have had a search and can't
find anything to point me in the right direction.

Can someone please help?


In Python 2.4, you don't need any additional libraries to do SSL on
the HTTP client side - Python 2.4 comes with SSL included (IIRC, you
didn't need these libraries in Python 2.2, either).

Just use httplib.HTTPS or httplib.HTTPSCo nnection instead.

Regards,
Martin
Jul 19 '05 #2
Thanks Martin. That means my code should work.

I am trying to go through a proxy, which works fine for HTTP sites.
However, when I try a HTTPS site, the program doesn't respond for quite
a while, and returns the error:

" File "C:\Python24\li b\urllib2.py", line 996, in do_open
raise URLError(err)
URLError: <urlopen error (8, 'EOF occurred in violation of protocol')>"

Here is my testing code:

import urllib2

proxy_info = {
'user' : 'me',
'pass' : 'mypassword',
'host' : 'proxy.mycompan y.com',
'port' : 8008 } # settings taken from web browser
# build a new opener that uses a proxy requiring authorization
proxy_support =
urllib2.ProxyHa ndler({"https": "https://%(user)s:%(pass )s@%(host)s:%(p ort)d"
% proxy_info})
opener = urllib2.build_o pener(proxy_sup port, urllib2.HTTPHan dler)

# install it
urllib2.install _opener(opener)

# use it
f = urllib2.urlopen ('https://www.directshare s.com.au')
print f.headers
f.close()

Any ideas what is wrong?

Bloke

Jul 19 '05 #3
I just removed my installation of Python 2.4.1, which was the one on
the python.org web site. I installed the Activepython 2.4.1 and now I
get the following error with the same code above:

File "C:\Python24\li b\urllib2.py", line 1053, in unknown_open
raise URLError('unkno wn url type: %s' % type)
URLError: <urlopen error unknown url type: https>

I'm getting a bit frustrated. Do I need to import another library?
Any advise is appreciated.

Bloke.

Jul 19 '05 #4
Bloke wrote:
I just removed my installation of Python 2.4.1, which was the one on
the python.org web site. I installed the Activepython 2.4.1 and now I
get the following error with the same code above:

File "C:\Python24\li b\urllib2.py", line 1053, in unknown_open
raise URLError('unkno wn url type: %s' % type)
URLError: <urlopen error unknown url type: https>

I'm getting a bit frustrated. Do I need to import another library?
Any advise is appreciated.

Bloke.


I think it's saying it doesn't understand the HTTPS protocol based on the

raise URL error('unknown url type: %' % type)
URLError: <urlopen error unknown url type: https>

--
--------------------------
Lucas Raab
lvraab"@"earthl ink.net
dotpyFE"@"gmail .com
AIM: Phoenix11890
MSN: dotpyfe "@" gmail.com
IRC: lvraab
ICQ: 324767918
Yahoo: Phoenix11890
Jul 19 '05 #5
Yes, on looking into it, sockets.ssl is not installed with
activepython, so it doesn't recognise https. So I have removed it, and
reinstalled the v 2.4.1 which I downloaded from www.python.org . This
leaves me with with the problem where the script 'hangs' for a long
time, then returns:

Traceback (most recent call last):
File "C:\Documen ts and
Settings\rhall\ Desktop\softwar e\python\auth_e xample_5.py", line 18, in
?
f = urllib2.urlopen ('https://www.directshare s.com.au/')
File "C:\Python24\Li b\urllib2.py", line 130, in urlopen
return _opener.open(ur l, data)
File "C:\Python24\Li b\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\Li b\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\Li b\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\Li b\urllib2.py", line 1029, in https_open
return self.do_open(ht tplib.HTTPSConn ection, req)
File "C:\Python24\Li b\urllib2.py", line 996, in do_open
raise URLError(err)
URLError: <urlopen error (8, 'EOF occurred in violation of protocol')>

I'm stuck...

Jul 19 '05 #6
I just tried the https connection through a friends internet connection
which uses a transparent proxy as follows:

import urllib2
f = urllib2.urlopen ('https://www.directshare s.com.au/')
print f.headers
print f.read()
f.close()

This works fine. So it must be a problem with either the proxyhandler
(in Python) or our proxy server. Given that I can connect to the site
through the proxy with a web browser, it must be something to do with
my the way I have set up the proxy handler in python. I have read
multiple ways of setting up the connection, and this is the only way I
can get it to run with http:

import urllib2

proxy_info = {
'user' : 'me',
'pass' : 'password',
'host' : 'companyproxy.c om.au',
'port' : 8008 }

# build a new opener that uses a proxy requiring authorization
proxy_support =
urllib2.ProxyHa ndler({"http":" http://%(user)s:%(pass )s@%(host)s:%(p ort)d"
% proxy_info})
opener = urllib2.build_o pener(proxy_sup port, urllib2.HTTPHan dler)

# install it
urllib2.install _opener(opener)
Is there a better way for me to do this?

Jul 19 '05 #7
Following my above comment, if my script works with http, then what is
the problem with https, even when I change the ProxyHandler to specify
https?

Jul 19 '05 #8
Bloke wrote:
Following my above comment, if my script works with http, then what is
the problem with https, even when I change the ProxyHandler to specify
https?


I believe there is a bug in the https implementations of certain Web
services, in particular the Microsoft-ish ones. They are supposed to
send a message to close the connection, but fail to do so. Instead,
they eventually shut down the connection (without sending a
CloseConnection message first).

So part of the problem is that your web server, in violation of the
protocol, just drops the connection.

The other question is why there is a period of inactivity. This, again,
may be the result of a misunderstandin g in the protocol implementations ,
of which the first problem is only a side effect (i.e. the server might
close the connection because of the inactivity).

This typically means that either side is expecting the other one to send
a message, but both sides fail to do so. Which one specifically is buggy
can only be determined by studying the messages sent back and forth in
more detail.

As a wild guess: try not to use HTTP/1.1, use HTTP/1.0 instead. To do
so, try not using urllib, use httplib directly.

Regards,
Martin

Jul 19 '05 #9
[Bloke wrote]
I just removed my installation of Python 2.4.1, which was the one on
the python.org web site. I installed the Activepython 2.4.1 and now I
get the following error with the same code above:

File "C:\Python24\li b\urllib2.py", line 1053, in unknown_open
raise URLError('unkno wn url type: %s' % type)
URLError: <urlopen error unknown url type: https>

I'm getting a bit frustrated. Do I need to import another library?
Any advise is appreciated.


Unfortunately ActivePython cannot include the SSL library by default
because of crypto export regulations. For SSL support in an ActivePython
installation you'd have to add the _ssl.pyd extension separately (either
building it yourself, or finding an available binary).

Sincerely,
Trent

--
Trent Mick
Tr****@ActiveSt ate.com
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
35764
by: NotGiven | last post by:
I need to verify if the page that led the user to this page used http or httpS. for example, if the use cam to my page from: httpS://www.dm.com/sample/foo.php I want to know as opposed to coming from: http://www.dm.com/sample/foo.php I've tried looking at PORT but it doesn't seem to work properly.
0
1782
by: kiran | last post by:
Hi, I hosted a PHP project on my web server(IIS) and I am accessing the ip addres through my office public address like this: (example) https://61.95.204.43:8887/phptest/test.php "https://61.95.204.43" is my company ip address and the port 8887 is any requests that are comes through the port(8887) will be redirected to my system, which is under the network ("https://61.95.204.43").
2
3284
by: Craig Keightley | last post by:
i have the following script on my checkout page to check if https is set in the address bar: if ($_SERVER != "on") { $url = $_SERVER; $query = $_SERVER; $path = $_SERVER; header("Location: https://$url$path?$query"); }
16
60615
by: Paul Sweeney | last post by:
Does anyone know of a working (python) https proxy which allows viewing of unencrypted data being sent from my browser to an https site? I've worked my way through most on the list at http://xhaus.com/alan/python/proxies.html, but while many claim to support https, if you actually point your browser at the proxies, they work fine for http, but not for https pages. TIA
12
5191
by: Grunff | last post by:
I'm experiencing an interesting problem with carrying a php session over from http to https. Much googling later, I'm still stuck. The application is an online shop, where some user data is stored in the session. As the user proceeds to checkout, we switch over to https. This is all done on the same physical server, under the same domain (which has an SSL cert). The session ID is carried over fine - I can read the session ID from http...
14
2516
by: Peter Chant | last post by:
I'm currently authenticating a site I have built using basic http authentication built into apache. This has zero overhead on php which is a bonus but it seems to not quite work how I'd like. Are the username and password in the login box that comes up encrypted? When I login https://mysite.local:portnum I get the login dialog. As I am using a self signed certificate I see the dialog stating warning me about it first before the login...
4
6527
by: Jason P | last post by:
Basically we have a web method with a dynamic URL. The client is developed in C++ and I've been using the webReference.SetUrl( "http://test.example.com..." ) method successfully with various web method URLs. However, when we switched to using a secure connection, the call to webReference.SetUrl( "https://test.example.com..." ) no longer functions. The SetUrl() method is actually successful, but any following calls in to the web...
14
3056
by: david | last post by:
I have developed web forms including login by using ASP.NET via HTTP. Now I want to secure the connection from client to the server via HTTPS. How can I configure the server or something else to make the change? Thank you David
2
5325
by: scott mcfadden | last post by:
Using VS 2003, I can not add a web reference to our production server's ..asmx URL using HTTPS. I will put in a URL like: https://mycompany.com/myapp/myservice.asmx VStudio will display the web methods from that URL and when I click on OK to download/build the dynamic web proxy code, I get the following error: Unable to download files from http://mycompany.com/myapp/myservice.asmx
0
2867
by: NoaGross | last post by:
Hi, I'm relly new in java and I have a problem. I'm using java applet. When using http all ok, but when trying to use https i get: Java Plug-in 1.5.0_10 Using JRE version 1.5.0_10 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\noa ---------------------------------------------------- c: clear console window
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.