Secure ssl connection with wrap_socket

Jean-Paul Calderone calderone.jeanpaul at gmail.com
Tue Jul 5 10:08:59 EDT 2011


On Jul 5, 4:52 am, Andrea Di Mario <anddima... at gmail.com> wrote:
> Hi, I'm a new python user and I'm writing a small web service with ssl.
> I want use a self-signed certificate like in wiki:http://docs.python.org/dev/library/ssl.html#certificates
> I've used wrap_socket, but if i try to use
> cert_reqs=ssl.CERT_REQUIRED, it doesn't work with error:
>
> urllib2.URLError: <urlopen error _ssl.c:326: No root certificates
> specified for verification of other-side certificates.>
>
> It works only with CERT_NONE (the default) but with this option i
> could access to the service in insicure mode.
>
> Have you some suggestions for my service?
>

Also specify some root certificates to use in verifying the peer's
certificate.  Certificate verification works by proceeding from a
collection of "root" certificates which are explicitly trusted.  These
are used to sign other certificates (which may in turn be used to sign
others, which in turn...).  The process of certificate verification is
the process of following the signatures from the certificate in use by
the server you connect to back up the chain until you reach a root
which you have either decided to trust or not.  If the signatures are
all valid and the root is one you trust, then you have established a
connection to a trusted entity.  If any signature is invalid, or the
root is not one you trust, then you have not.

The root certificates are also called the "ca certificates" or
"certificate authority certificates".  `wrap_socket` accepts a
`ca_certs` argument.  See http://docs.python.org/library/ssl.html#ssl-certificates
for details about that argument.

Jean-Paul



More information about the Python-list mailing list