473,786 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using HTTPSConnection and verifying server's CRT

Hi,

I'm trying to build a system using HTTPS with python clients that have
to verify the server's identity. From the Python document, it seems that
the server's certificate is not veryfied, and authentication can only be
in the other way (client authentication) .
I know usually users only click on 'yes I trust this certificate', but
what if you really care (this is my case)?

I tried to see if the M2Crypto has this possibility, but from my tests
and from what I can find on the website, it seems not :/

Can someone confirm me this is not possible or point me to something
that could help me?

Thanks,
Marc
Jul 18 '05 #1
4 2893
According to Marc Poulhiès <ma************ ******@epfl.ch> :
I tried to see if the M2Crypto has this possibility, but from my tests
and from what I can find on the website, it seems not :/
How did you test and where on the website does it say not?
Can someone confirm me this is not possible or point me to something
that could help me?


M2Crypto does server cert verification. With M2Crypto's httpslib, you pass
in an SSL.Context instance to the HTTPSConnection constructor to configure
the SSL; one of the config knobs is cert verification. So, redo your test,
satisfy yourself that this is doable, and send me your code to include as
an example in the distribution. ;-)

M2Crypto even does client certs. Since Apr 2000, according to the very last
blog entry on the ZServerSSL page.
--
Ng Pheng Siong <ng**@netmemeti c.com>

http://sandbox.rulemaker.net/ngps -+- M2Crypto, ZServerSSL for Zope, Blog
http://www.sqlcrypt.com -+- Database Engine with Transparent AES Encryption
Jul 18 '05 #2
ng**@netmemetic .com (Ng Pheng Siong) writes:

Hi,
According to Marc Poulhiès <ma************ ******@epfl.ch> :
I tried to see if the M2Crypto has this possibility, but from my tests
and from what I can find on the website, it seems not :/
How did you test and where on the website does it say not?


I did things like this:
con = M2Crypto.httpsl ib.HTTPSConnect ion("some_secur e_server")
con.request("GE T" , "/")

I tried to play with optional parameters (strict, debuglevel, etc) to
see if it was saying that it will not check server's CRT or some other
debug message dealing with server's certificate, but it is always
returning the webpage without saying anything :)

I did not say that M2C's doc stated clearly that this was not possible
(that's why I wrote "seems"), but I couldn't find something stating it
was possible (I tried google, API docs).
Can someone confirm me this is not possible or point me to something
that could help me?


M2Crypto does server cert verification. With M2Crypto's httpslib, you pass
in an SSL.Context instance to the HTTPSConnection constructor to configure
the SSL; one of the config knobs is cert verification. So, redo your test,
satisfy yourself that this is doable, and send me your code to include as
an example in the distribution. ;-)


Ok, sorry for that. Maybe that with more readings I could have spotted
this. I'll try that tomorrow and give my code if I have something
working!

M2Crypto even does client certs. Since Apr 2000, according to the very last
blog entry on the ZServerSSL page.


Yes, I did try this and have my client authenticated to the server.

Thanks for this quick and clear answer ;)

Marc
Jul 18 '05 #3
Marc Poulhiès <ma***********@ NO-SP4Mepfl.ch> writes:
ng**@netmemetic .com (Ng Pheng Siong) writes:

M2Crypto does server cert verification. With M2Crypto's httpslib, you pass
in an SSL.Context instance to the HTTPSConnection constructor to configure
the SSL; one of the config knobs is cert verification. So, redo your test,
satisfy yourself that this is doable, and send me your code to include as
an example in the distribution. ;-)


Hi again!

So here are few lines that do server's CRT check. I still have one
question: see in the code. Both have the exact same description on
the documentation.

Btw, thanks for your answer (this will save me from using Perl!)
Marc

---8<-------8<-------8<-------8<----
#!/usr/bin/env python
import M2Crypto

ctx = M2Crypto.SSL.Co ntext()

## what are the diff between these two??
#ctx.load_verif y_info(cafile="/tmp/ca.crt")
ctx.load_verify _locations(cafi le="/tmp/ca.crt")

# load client certificate (used to authenticate the client)
ctx.load_cert("/tmp/client.crt")

# stop if peer's certificate can't be verified
ctx.set_allow_u nknown_ca(False )

# verify peer's certificate
ctx.set_verify( M2Crypto.SSL.ve rify_peer, 1)

con = M2Crypto.httpsl ib.HTTPSConnect ion("my.ssl.ser ver.domain",ssl _context=ctx)

con.request("GE T" , "/")
print con.getresponse ().read()
---8<-------8<-------8<-------8<-----

Result here:
$ ./ssl_peer_verif. py
Enter passphrase:
send: 'GET / HTTP/1.1\r\nHost: my.ssl.server.d omain:443\r\nAc cept-Encoding: identity\r\n\r\ n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Tue, 01 Feb 2005 08:41:51 GMT
header: Server: Apache/2.0.46 (Red Hat)
header: Last-Modified: Mon, 31 Jan 2005 14:50:50 GMT
header: ETag: "4297-13-24658680"
header: Accept-Ranges: bytes
header: Content-Length: 19
header: Connection: close
header: Content-Type: text/html; charset=UTF-8
THIS IS WORKING =)
Jul 18 '05 #4
According to Marc Poulhiès <ma***********@ NO-SP44Mepfl.ch>:
Btw, thanks for your answer (this will save me from using Perl!)
You're welcome.
## what are the diff between these two??
#ctx.load_verif y_info(cafile="/tmp/ca.crt")
ctx.load_verify _locations(cafi le="/tmp/ca.crt")
None. One is an alias for the other, to adhere to OpenSSL's naming
convention.
$ ./ssl_peer_verif. py
Enter passphrase:
send: 'GET / HTTP/1.1\r\nHost:
my.ssl.server.d omain:443\r\nAc cept-Encoding: identity\r\n\r\ n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Tue, 01 Feb 2005 08:41:51 GMT
header: Server: Apache/2.0.46 (Red Hat)
header: Last-Modified: Mon, 31 Jan 2005 14:50:50 GMT
header: ETag: "4297-13-24658680"
header: Accept-Ranges: bytes
header: Content-Length: 19
header: Connection: close
header: Content-Type: text/html; charset=UTF-8
THIS IS WORKING =)


Excellent! ;-)
--
Ng Pheng Siong <ng**@netmemeti c.com>

http://sandbox.rulemaker.net/ngps -+- M2Crypto, ZServerSSL for Zope, Blog
http://www.sqlcrypt.com -+- Database Engine with Transparent AES Encryption
Jul 18 '05 #5

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

Similar topics

2
4048
by: John Glista | last post by:
Hello. I'm having a bit of a problem with the HTTPSConnection class. It is part of the httplib module. I discovered that it is not neccessary to specifiy a key and a certificate when opening an HTTPS connection. I tested this with several sites, and successfully opened https connections with them. However, I'm having problems with the server I'm trying to connect to. It is a Novell Bordermanager server that tunnels all Internet...
0
2454
by: Terry Kerr | last post by:
Hi, I have an app that makes a https POST to a remote server that I have no control over. The app runs fine in python 2.1.3 with socket.ssl compiled with openssl-0.9.6, however it will not run in python 2.3.3 compiled with openssl-0.9.7d. The script below demonstrates the problem. ============================================ import httplib path = "/cmaonline.nsf/ePayForm?OpenForm"
0
2935
by: Robert | last post by:
did you solve this problem? It seems to be still present here with py2.3.5. Robert -- From: Manish Jethani <manish.j@gmx.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en
6
2835
by: Paul Winkler | last post by:
This is driving me up the wall... any help would be MUCH appreciated. I have a module that I've whittled down into a 65-line script in an attempt to isolate the cause of the problem. (Real domain names have been removed in everything below.) SYNOPSIS: I have 2 target servers, at https://A.com and https://B.com. I have 2 clients, wget and my python script.
0
1197
by: Huzaifa Tapal | last post by:
is it reccommended to us the HTTPSConnection object to make socket connections in a multithreaded persistent environment? The reason I ask is that I am having intermittent problems with possibly stale socket objects being return from the _socket module which is causing some pain in my application. Any help would be appreciated. Hozi
9
2106
by: Carter Smith | last post by:
http://www.icarusindie.com/wiki/index.php/Server-Side_Javascript_Check Sample source included This method requires that your pages are PHP enabled and you have mySQL. Although I suppose you could also use PHP sessions (not cookies as they're client editable). You could actually use any server side scripting language such as Perl or ASP and any database like MS SQL Server. I prefer PHP and MySQL.
5
4028
by: Geisler, Jim | last post by:
So, as far as I know, PostgreSQL does not have any way of verifying the loss of referential integrity. Are there any recommended methods or utilities for checking referential integrity in a PostgreSQL database?
0
1553
by: xievvv | last post by:
I am trying to have a SslStream client and an SslStream server mutually authenticate and communicate with each other, over TCP. So when I call the methods AuthenticateAsClient() and AuthenticateAsServer() with CRL checking disabled (last argument: false) everything works fine. Now I want to incorporate CRL checking during the validation process. When I specify the CRL checking argument: true, I get RemoteCertificateChainErrors on both the...
7
3518
seligerasmus
by: seligerasmus | last post by:
Greetings! My scenario is such - I'm wrapping a Java web service around a set of RPG programs that live on one of my company's i-Series (AS/400) midrange computers. To faciltate the connectivity between the Java application server and the i-Series box, I'm using IBM's Toolbox for Java. My circumstances allow me to use previously-written PCML specification files in my code. I can verify that these PCML files are in use in my company's...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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...
0
9964
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
8993
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
7517
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
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.