Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:48:40+00:00 2026-05-31T05:48:40+00:00

The Problem: Python’s ssl module is not complaining about a certificate, although the issuing

  • 0

The Problem:

Python’s ssl module is not complaining about a certificate, although the issuing CA is not provided in the cacert.pem file (Test Case 2. below). I use CAs extracted from Mozilla. Firefox is correctly complaining about the unknown CA (in this case the Department of Defence).

It seems as only the certificate itself get’s validated, not that the CA is known. I am running Python 2.7.1 and using ssl version OpenSSL 0.9.8r.

The Test Cases:

Check the following sites in Firefox and with the python example client below.

  1. https://www.verisign.com – should work, CA is known
  2. https://www.us.army.mil – should not work, as CA is not known
  3. https://www.pcwebshop.co.uk – should not work, only Parallels Panel certificate

Case 2. gets validated by the python client although it shouldn’t.

Case 3. throws an Exception as expected:

routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

The Example Python Client:

CA file: http://curl.haxx.se/ca/cacert.pem (mozilla’s default CAs by curl maintainers).

Slightly modified version of http://docs.python.org/library/ssl.html#client-side-operation:

# test_ssl.py   
import socket, ssl, pprint, sys
host = sys.argv[1]

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# require a certificate from the server
ssl_sock = ssl.wrap_socket(s,
                           # http://curl.haxx.se/ca/cacert.pem
                           ca_certs="cacert.pem", 
                           cert_reqs=ssl.CERT_REQUIRED)

ssl_sock.connect((host, 443))

print repr(ssl_sock.getpeername())
print ssl_sock.cipher()
print pprint.pformat(ssl_sock.getpeercert())

# Set a simple HTTP request -- use httplib in actual code.
ssl_sock.write("""GET / HTTP/1.0\r
Host: """ + host + """\r\n\r\n""")

# Read a chunk of data.  Will not necessarily
# read all the data returned by the server.
data = ssl_sock.read()
print data

# note that closing the SSLSocket will also close the underlying socket
ssl_sock.close()

Usage:

python test_ssl.py www.verisign.com
python test_ssl.py www.us.army.mil
python test_ssl.py www.pcwebshop.co.uk

UPDATE:

With the help of strcat and others i could confirm this behavior is specific to:

  • OSX Lion 10.7.1
  • Python 2.7.1 & Python 2.6.7
  • OpenSSL 0.9.8r 8 Feb 2011

I tested on two macs and several other boxes. I have the suspicion OpenSSL on mac uses a second source of CA certificates beside the file i pass to it. Maybe this makes http://www.us.army.mil a special testcase, as safari seems to trust it out of the box, too. Does anyone know other big self signed sites or how openssl on mac works?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:48:41+00:00Added an answer on May 31, 2026 at 5:48 am

    The Solution is:

    Through testing i could confirm, that on OSX openssl does use the system CA certificate store, even if not specified as seen in the python example above.

    I used http://www.us.army.mil as a testcase as it is known to be a self signed site (http://royal.pingdom.com/2008/08/19/new-ssl-policy-in-firefox-hurting-tens-of-thousands-of-sites/). As it turns out the system CA certificates on OSX contain two DoD certificates and so Safari doesn’t complain, and also my python test client.

    If i untrust those certificates in Keychan Access -> System Roots -> Certificates the python client shows the expected behavior, which confirms that python ssl / OpenSSL uses the system root certificates on OSX 10.7.1 whether specified or not. I don’t know if this is the expected behavior but it sure surprised me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with python module import. I installed django (this can be
Django python problem: The select drop down returns the numeric value of the item.
Im having a problem with python.. I have a binary tree node type: class
I have problem concerning python packages and testing. I'm writing an application using wx
I have a problem in Python. How can I increment by one fully automatically
I'm having a problem with Python's subprocess.Popen method. Here's a test script which demonstrates
Whilst I'd love to solve this problem in python, I'm stuck in Delphi for
Having a problem executing a Python script from a .NET web service. The web
I have a problem of upgrading python from 2.4 to 2.6: I have CentOS
I'm having a problem with my python script. It's printing massive amounts of data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.