gevent._ssl2
– SSL wrapper for socket objects on Python 2.7.8 and below¶For the documentation, refer to ssl
module manual.
This module implements cooperative SSL socket wrappers.
Deprecated since version 1.3: This module is not secure. Support for Python versions with only this level of SSL will be dropped in gevent 1.4.
SSLSyscallError
¶Bases: ssl.SSLError
System error when attempting SSL operation.
SSLError
¶Bases: socket.error
An error occurred in the SSL implementation.
SSLZeroReturnError
¶Bases: ssl.SSLError
SSL/TLS session closed cleanly.
SSLEOFError
¶Bases: ssl.SSLError
SSL/TLS connection terminated abruptly.
SSLWantWriteError
¶Bases: ssl.SSLError
Non-blocking SSL socket needs to write more data before the requested operation can be completed.
SSLWantReadError
¶Bases: ssl.SSLError
Non-blocking SSL socket needs to read more data before the requested operation can be completed.
DefaultVerifyPaths
(cafile, capath, openssl_cafile_env, openssl_cafile, openssl_capath_env, openssl_capath)¶Bases: tuple
Create new instance of DefaultVerifyPaths(cafile, capath, openssl_cafile_env, openssl_cafile, openssl_capath_env, openssl_capath)
cafile
¶Alias for field number 0
capath
¶Alias for field number 1
openssl_cafile
¶Alias for field number 3
openssl_cafile_env
¶Alias for field number 2
openssl_capath
¶Alias for field number 5
openssl_capath_env
¶Alias for field number 4
SSLSocket
(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=0, ssl_version=2, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True, ciphers=None)[source]¶Bases: gevent._socket2.socket
gevent ssl.SSLSocket for Pythons < 2.7.9.
accept
()[source]¶Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.
getpeercert
(binary_form=False)[source]¶Returns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.
Purpose
[source]¶Bases: ssl._ASN1Object
SSLContext purpose flags with X509v3 Extended Key Usage objects
closing
(thing)[source]¶Bases: object
Context to automatically close something at the end of a block.
Code like this:
- with closing(<module>.open(<arguments>)) as f:
- <block>
is equivalent to this:
f = <module>.open(<arguments>) try:
<block>
- finally:
- f.close()
SSLContext
(protocol)[source]¶Bases: _ssl._SSLContext
An SSLContext holds various SSL-related configuration options and data, such as certificates and possibly a private key.
create_default_context
(purpose=_ASN1Object(nid=129, shortname='serverAuth', longname='TLS Web Server Authentication', oid='1.3.6.1.5.5.7.3.1'), cafile=None, capath=None, cadata=None)[source]¶Create a SSLContext object with default settings.
create_connection
(address, timeout=<object object>, source_address=None)[source]¶Connect to address and return the socket object.
Convenience function. Connect to address (a 2-tuple (host,
port)
) and return the socket object. Passing the optional
timeout parameter will set the timeout on the socket instance
before attempting to connect. If no timeout is supplied, the
global default timeout setting returned by getdefaulttimeout()
is used. If source_address is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
A host of ‘’ or port 0 tells the OS to use the default.
sslwrap_simple
(sock, keyfile=None, certfile=None)[source]¶A replacement for the old socket.ssl function. Designed for compatibility with Python 2.5 and earlier. Will disappear in Python 3.0.
cert_time_to_seconds
(cert_time)[source]¶Return the time in seconds since the Epoch, given the timestring
representing the “notBefore” or “notAfter” date from a certificate
in "%b %d %H:%M:%S %Y %Z"
strptime format (C locale).
“notBefore” or “notAfter” dates must use UTC (RFC 5280).
Month is one of: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec UTC should be specified as GMT (see ASN1_TIME_print())
DER_cert_to_PEM_cert
(der_cert_bytes)[source]¶Takes a certificate in binary DER format and returns the PEM version of it as a string.
match_hostname
(cert, hostname)[source]¶Verify that cert (in decoded format as returned by SSLSocket.getpeercert()) matches the hostname. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for hostname.
CertificateError is raised on failure. On success, the function returns nothing.
get_server_certificate
(addr, ssl_version=2, ca_certs=None)[source]¶Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If ‘ca_certs’ is specified, validate the server cert against it. If ‘ssl_version’ is specified, use it in the connection attempt.
RAND_status
() → 0 or 1¶Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not. It is necessary to seed the PRNG with RAND_add() on some platforms before using the ssl() function.
RAND_add
(string, entropy)¶Mix string into the OpenSSL PRNG state. entropy (a float) is a lower bound on the entropy contained in string. See RFC 1750.
Next page: gevent.select
– Waiting for I/O completion