Service identity verification for pyOpenSSL.
Project description
WARNING
This software is currently alpha and under review. Use it at your own peril.
Any part is subject to change, but feedback is very welcome!
Pitch
service_identity aspires to give you all the tools you need for verifying whether a certificate is valid for the intended purposes.
In the simplest case, this means host name verification. However, service_identity implements RFC 6125 fully and plans to add other relevant RFCs too.
Features
Present
Future
Usage
Verify a Hostname
The simplest, most common, and most important usage:
from __future__ import absolute_import, division, print_function
import socket
from OpenSSL import SSL
from service_identity import VerificationError
from service_identity.pyopenssl import verify_hostname
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.set_verify(SSL.VERIFY_PEER, lambda conn, cert, errno, depth, ok: ok)
ctx.set_default_verify_paths()
hostname = u"twistedmatrix.com"
conn = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM))
conn.connect((hostname, 443))
try:
conn.do_handshake()
verify_hostname(conn, hostname)
# Do your super-secure stuff here.
except SSL.Error as e:
print("TLS Handshake failed: {0!r}.".format(e.args[0]))
except VerificationError:
print("Presented certificate is not valid for {0}.".format(hostname))
finally:
conn.shutdown()
conn.close()
Requirements
Python 2.6, 2.7, 3.2, 3.3, and 3.4 as well as PyPy are supported.
Additionally, the following PyPI modules are required:
pyOpenSSL >= 0.12 (0.14 strongly suggested)
Optionally, idna can be used for internationalized domain names (IDN), aka non-ASCII domains. Please note, that idna is not available for Python 3.2 and is required because Python’s stdlib support is outdated.
History
0.2.0 (2014-04-06)
This release contains multiple backward-incompatible changes.
Refactor into a multi-module package. Most notably, verify_hostname and extract_ids live in the service_identity.pyopenssl module now.
verify_hostname now takes an OpenSSL.SSL.Connection for the first argument.
Less false positives in IP address detection.
Officially support Python 3.4 too.
More strict checks for URI_IDs.
0.1.0 (2014-03-03)
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file service_identity-0.2.tar.gz
.
File metadata
- Download URL: service_identity-0.2.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adb0f07b541fb40b9c023f40e1e7520ea382d8d692c22d37e08236dc2552e1f4 |
|
MD5 | 5fd2b5103291e71b3afe23aaeefb89f2 |
|
BLAKE2b-256 | ab22d6c2eed070cc6b95681925560a611c80438e44e7bb4cd2b1201597255ddf |
File details
Details for the file service_identity-0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: service_identity-0.2-py2.py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3a288ddb23448e8c6498af3d7a1f1348569b3a18a4c3e645c72e180692523d1 |
|
MD5 | 859428617de6ac522b781a3d0a1d6689 |
|
BLAKE2b-256 | 4c0a0e7f5420f90d99846163a1ffa9a6b1be29fffbaf7e6d3827cda4293f53ae |