See X509.
A class representing X.509 certificates.
See X509Name.
A class representing X.509 Distinguished Names.
This constructor creates a copy of x509name which should be an instance of X509Name.
See X509Req.
A class representing X.509 certificate requests.
A Python type object representing the X509Store object type.
See PKey.
A class representing DSA or RSA keys.
A Python type object representing the PKCS7 object type.
A Python type object representing the PKCS12 object type.
See X509Extension.
A class representing an X.509 v3 certificate extensions. See http://openssl.org/docs/apps/x509v3_config.html#STANDARD_EXTENSIONS for typename strings and their options. Optional parameters subject and issuer must be X509 objects.
See NetscapeSPKI.
A class representing Netscape SPKI objects.
If the enc argument is present, it should be a base64-encoded string representing a NetscapeSPKI object, as returned by the b64_encode() method.
A class representing Certifcate Revocation List objects.
A class representing Revocation objects of CRL.
File type constants.
Key type constants.
Generic exception used in the crypto module.
Dump the certificate cert into a buffer string encoded with the type type.
Dump the certificate request req into a buffer string encoded with the type type.
Dump the private key pkey into a buffer string encoded with the type type, optionally (if type is FILETYPE_PEM) encrypting it using cipher and passphrase.
passphrase must be either a string or a callback for providing the pass phrase.
Load a certificate (X509) from the string buffer encoded with the type type.
Load a certificate request (X509Req) from the string buffer encoded with the type type.
Load a private key (PKey) from the string buffer encoded with the type type (must be one of FILETYPE_PEM and FILETYPE_ASN1).
passphrase must be either a string or a callback for providing the pass phrase.
Load Certificate Revocation List (CRL) data from a string buffer. buffer encoded with the type type. The type type must either FILETYPE_PEM or FILETYPE_ASN1).
Load pkcs7 data from the string buffer encoded with the type type.
Load pkcs12 data from the string buffer. If the pkcs12 structure is encrypted, a passphrase must be included. The MAC is always checked and thus required.
See also the man page for the C function PKCS12_parse().
Sign a data string using the given key and message digest.
key is a PKey instance. data is a str instance. digest is a str naming a supported message digest type, for example sha1.
New in version 0.11.
Verify the signature for a data string.
certificate is a X509 instance corresponding to the private key which generated the signature. signature is a str instance giving the signature itself. data is a str instance giving the data to which the signature applies. digest is a str instance naming the message digest type of the signature, for example sha1.
New in version 0.11.
X509 objects have the following methods:
Return an X509Name object representing the issuer of the certificate.
Return a PKey object representing the public key of the certificate.
Return the certificate serial number.
Return the signature algorithm used in the certificate. If the algorithm is undefined, raise ValueError.
..versionadded:: 0.13
Return an X509Name object representing the subject of the certificate.
Return the certificate version.
Return a string giving the time before which the certificate is not valid. The string is formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ YYYYMMDDhhmmss+hhmm YYYYMMDDhhmmss-hhmm
If no value exists for this field, None is returned.
Return a string giving the time after which the certificate is not valid. The string is formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ YYYYMMDDhhmmss+hhmm YYYYMMDDhhmmss-hhmm
If no value exists for this field, None is returned.
Change the time before which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ YYYYMMDDhhmmss+hhmm YYYYMMDDhhmmss-hhmm
Change the time after which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ YYYYMMDDhhmmss+hhmm YYYYMMDDhhmmss-hhmm
Adjust the timestamp (in GMT) when the certificate starts being valid.
Adjust the timestamp (in GMT) when the certificate stops being valid.
Checks the certificate’s time stamp against current time. Returns true if the certificate has expired and false otherwise.
Set the issuer of the certificate to issuer.
Set the public key of the certificate to pkey.
Set the serial number of the certificate to serialno.
Set the subject of the certificate to subject.
Set the certificate version to version.
Sign the certificate, using the key pkey and the message digest algorithm identified by the string digest.
Return the hash of the certificate subject.
Return a digest of the certificate, using the digest_name method. digest_name must be a string describing a digest algorithm supported by OpenSSL (by EVP_get_digestbyname, specifically). For example, "md5" or "sha1".
Add the extensions in the sequence extensions to the certificate.
Return the number of extensions on this certificate.
New in version 0.12.
Retrieve the extension on this certificate at the given index.
Extensions on a certificate are kept in order. The index parameter selects which extension will be returned. The returned object will be an X509Extension instance.
New in version 0.12.
X509Name objects have the following methods:
Return an integer giving the first four bytes of the MD5 digest of the DER representation of the name.
Return a string giving the DER representation of the name.
Return a list of two-tuples of strings giving the components of the name.
X509Name objects have the following members:
The country of the entity. C may be used as an alias for countryName.
The state or province of the entity. ST may be used as an alias for stateOrProvinceName.
The locality of the entity. L may be used as an alias for localityName.
The organization name of the entity. O may be used as an alias for organizationName.
The organizational unit of the entity. OU may be used as an alias for organizationalUnitName.
The common name of the entity. CN may be used as an alias for commonName.
The e-mail address of the entity.
X509Req objects have the following methods:
Return a PKey object representing the public key of the certificate request.
Return an X509Name object representing the subject of the certificate.
Set the public key of the certificate request to pkey.
Sign the certificate request, using the key pkey and the message digest algorithm identified by the string digest.
Verify a certificate request using the public key pkey.
Set the version (RFC 2459, 4.1.2.1) of the certificate request to version.
Get the version (RFC 2459, 4.1.2.1) of the certificate request.
The X509Store object has currently just one method:
Add the certificate cert to the certificate store.
The PKey object has the following methods:
Return the number of bits of the key.
Generate a public/private key pair of the type type (one of TYPE_RSA and TYPE_DSA) with the size bits.
Return the type of the key.
Check the consistency of this key, returning True if it is consistent and raising an exception otherwise. This is only valid for RSA keys. See the OpenSSL RSA_check_key man page for further limitations.
PKCS7 objects have the following methods:
FIXME
FIXME
FIXME
FIXME
Get the type name of the PKCS7.
PKCS12 objects have the following methods:
Returns a PKCS12 object as a string.
The optional passphrase must be a string not a callback.
See also the man page for the C function PKCS12_create().
Return CA certificates within the PKCS12 object as a tuple. Returns None if no CA certificates are present.
Return certificate portion of the PKCS12 structure.
Return friendlyName portion of the PKCS12 structure.
Return private key portion of the PKCS12 structure
Replace or set the CA certificates within the PKCS12 object with the sequence cacerts.
Set cacerts to None to remove all CA certificates.
Replace or set the certificate portion of the PKCS12 structure.
Replace or set the friendlyName portion of the PKCS12 structure.
Replace or set private key portion of the PKCS12 structure
X509Extension objects have several methods:
Return the critical field of the extension object.
Retrieve the short descriptive name for this extension.
The result is a byte string like basicConstraints.
New in version 0.12.
Retrieve the data for this extension.
The result is the ASN.1 encoded form of the extension data as a byte string.
New in version 0.12.
NetscapeSPKI objects have the following methods:
Return a base64-encoded string representation of the object.
Return the public key of object.
Set the public key of the object to key.
Sign the NetscapeSPKI object using the given key and digest_name. digest_name must be a string describing a digest algorithm supported by OpenSSL (by EVP_get_digestbyname, specifically). For example, "md5" or "sha1".
Verify the NetscapeSPKI object using the given key.
CRL objects have the following methods:
Add a Revoked object to the CRL, by value not reference.
Use cert and key to sign the CRL and return the CRL as a string. days is the number of days before the next CRL is due.
Return a tuple of Revoked objects, by value not reference.
Revoked objects have the following methods:
Return a list of all supported reasons.
Return the revocation reason as a str. Can be None, which differs from “Unspecified”.
Return the revocation date as a str. The string is formatted as an ASN1 GENERALIZEDTIME.
Return a str containing a hex number of the serial of the revoked certificate.
Set the revocation reason. reason must be None or a string, but the values are limited. Spaces and case are ignored. See all_reasons().
Set the revocation date. The string is formatted as an ASN1 GENERALIZEDTIME.
serial is a string containing a hex number of the serial of the revoked certificate.
This module handles the OpenSSL pseudo random number generator (PRNG) and declares the following:
Mix bytes from string into the PRNG state. The entropy argument is (the lower bound of) an estimate of how much randomness is contained in string, measured in bytes. For more information, see e.g. RFC 1750.
Get some random bytes from the PRNG as a string.
This is a wrapper for the C function RAND_bytes().
Erase the memory used by the PRNG.
This is a wrapper for the C function RAND_cleanup().
Query the Entropy Gathering Daemon on socket path for bytes bytes of random data and uses add() to seed the PRNG. The default value of bytes is 255.
Read bytes bytes (or all of it, if bytes is negative) of data from the file path to seed the PRNG. The default value of bytes is -1.
Add the current contents of the screen to the PRNG state.
Availability: Windows.
This is equivalent to calling add() with entropy as the length of the string.
Returns true if the PRNG has been seeded with enough data, and false otherwise.
Write a number of random bytes (currently 1024) to the file path. This file can then be used with load_file() to seed the PRNG again.
If the current RAND method supports any errors, this is raised when needed. The default method does not raise this when the entropy pool is depleted.
Whenever this exception is raised directly, it has a list of error messages from the OpenSSL error queue, where each item is a tuple (lib, function, reason). Here lib, function and reason are all strings, describing where and what the problem is. See err(3) for more information.
This module handles things specific to SSL. There are two objects defined: Context, Connection.
OpenSSL includes a couple of work-arounds to provide better compatibility with servers and clients. The following options are enabled when passing OP_ALL to the set_options() method of Context objects.
The documentation for these options was taken from the OpenSSL documentation of the corresponding SSL_CTX_set_options() function.
Constant used with set_options() of Context objects.
Work-around for an old www.microsoft.com bug.
When talking SSLv2, if session-id reuse is performed, the session-id passed back in the server-finished message is different from the one decided upon.
Constant used with set_options() of Context objects.
Work-around for an old Netscape-Commerce bug.
Netscape-Commerce/1.12, when talking SSLv2, accepts a 32 byte challenge but then appears to only use 16 bytes when generating the encryption keys. Using 16 bytes is ok but it should be ok to use 32. According to the SSLv3 spec, one should use 32 bytes for the challenge when operating in SSLv2/v3 compatibility mode, but as mentioned above, this breaks this server so 16 bytes is the way to go.
Constant used with set_options() of Context objects.
As of OpenSSL 0.9.8q and 1.0.0c, this option has no effect.
Constant used with set_options() of Context objects.
This option has no effect in OpenSSL 1.0.1.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
This option has no effect in OpenSSL 1.0.1.
Constant used with set_options() of Context objects.
Don’t prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X. OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
Disables a countermeasure against a SSL 3.0/TLS 1.0 protocol vulnerability affecting CBC ciphers, which cannot be handled by some broken SSL implementations. This option has no effect for connections using other ciphers.
Constant used with set_options() of Context objects.
Adds a padding extension to ensure the ClientHello size is never between 256 and 511 bytes in length. This is needed as a workaround for some implementations.
Constant used with set_options() of Context objects.
All of the above bug workarounds.
It is usually safe to use OP_ALL to enable the above bug workaround options.
The following additional options are available, but are not enabled by passing in OP_ALL.
Constant used with set_options() of Context objects.
Disable version rollback attack detection.
During the client key exchange, the client must send the same information about acceptable SSL/TLS protocol levels as during the first hello. Some clients violate this rule by adapting to the server’s answer. (Example: the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server only understands up to SSLv3. In this case the client must still use the same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect to the server’s answer and violate the version rollback protection.)
Constant used with set_options() of Context objects.
Always create a new key when using temporary/ephemeral DH parameters.
This option must be used to prevent small subgroup attacks, when the DH parameters were not generated using “strong” primes. If “strong” primes were used, it is not strictly necessary to generate a new DH key during each handshake but it is also recommended. SSL_OP_SINGLE_DH_USE should therefore be enabled whenever temporary/ephemeral DH parameters are used.
Constant used with set_options() of Context objects.
Always use ephemeral (temporary) RSA key when doing RSA operations.
According to the specifications this is only done, when a RSA key can only be used for signature operations (namely under export ciphers with restricted RSA key length). By setting this option, ephemeral RSA keys are always used. This option breaks compatibility with the SSL/TLS specifications and may lead to interoperability problems with clients and should therefore never be used. Ciphers with DHE (ephemeral Diffie-Hellman) key exchange should be used instead.
Constant used with set_options() of Context objects.
When choosing a cipher, use the server’s preferences instead of the client preferences.
When not set, the SSL server will always follow the clients preferences. When set, the SSLv3/TLSv1 server will choose following its own preferences. Because of the different protocol for SSLv2, the server will send its list of preferences to the client and the client chooses.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
Work-around for an old Netscape browser bug.
If we accept a Netscape connection, demand a client cert, have a non-self-signed CA which does not have its CA in Netscape, and the browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
Constant used with set_options() of Context objects.
Undocumented.
Constant used with set_options() of Context objects.
When performing renegotiation as a server, always start a new session (i.e., session resumption requests are only accepted in the initial handshake). This option is not needed for clients.
Constant used with set_options() of Context objects.
Allow legacy insecure renegotiation between OpenSSL and unpatched clients or servers.
Constant used with set_options() of Context objects.
Normally clients and servers will, where possible, transparently make use of RFC4507bis tickets for stateless session resumption.
If this option is set this functionality is disabled and tickets will not be used by clients or servers.
Constant used with set_options() of Context objects.
When this option is used, compression will not be used.
Constant used with set_options() of Context objects.
Allow legacy insecure renegotiation between OpenSSL and unpatched servers only: this option is currently set by default.
Constants used with set_options() of Context objects.
Each of these options disables one version of the SSL/TLS protocol. This is interesting if you’re using e.g. SSLv23_METHOD to get an SSLv2-compatible handshake, but don’t want to use SSLv2. If the underlying OpenSSL build is missing support for any of these protocols, the OP_NO_* constant may be undefined.
Other symbols used in OpenSSL.
These constants represent the different SSL methods to use when creating a context object. If the underlying OpenSSL build is missing support for any of these protocols, constructing a Context using the corresponding *_METHOD will raise an exception.
These constants represent the verification mode used by the Context object’s set_verify() method.
File type constants used with the use_certificate_file() and use_privatekey_file() methods of Context objects.
Constant used with set_mode() of Context objects to allow releasing no longer needed buffers in the SSL context on idle connections.
Constant used with set_mode() of Context objects on OpenSSL clients to allow sending TLS_FALLBACK_SCSV in the ClientHello message. See draft-ietf-tls-downgrade-scsv-00 for details.
This should only be used in explicit fallback retries, not in normal handshakes.
Note that OpenSSL servers (starting with OpenSSL 1.0.1j) automatically have this enabled to prevent TLS downgrade attacks.
Constants used with SSLeay_version() to specify what OpenSSL version information to retrieve. See the man page for the SSLeay_version() C API for details.
Constants used with Context.set_session_cache_mode() to specify the behavior of the session cache and potential session reuse. See the man page for the SSL_CTX_set_session_cache_mode() C API for details.
New in version 0.14.
An integer giving the version number of the OpenSSL library used to build this version of pyOpenSSL. See the man page for the SSLeay_version() C API for details.
Retrieve a string describing some aspect of the underlying OpenSSL version. The type passed in should be one of the SSLEAY_* constants defined in this module.
See Context.
A class representing SSL contexts. Contexts define the parameters of one or more SSL connections.
method should be SSLv2_METHOD, SSLv3_METHOD, SSLv23_METHOD, TLSv1_METHOD, TLSv1_1_METHOD, or TLSv1_2_METHOD.
A class representing an SSL session. A session defines certain connection parameters which may be re-used to speed up the setup of subsequent connections.
New in version 0.14.
See Connection.
A class representing SSL connections.
context should be an instance of Context and socket should be a socket [1] object. socket may be None; in this case, the Connection is created with a memory BIO: see the bio_read(), bio_write(), and bio_shutdown() methods.
This exception is used as a base class for the other SSL-related exceptions, but may also be raised directly.
Whenever this exception is raised directly, it has a list of error messages from the OpenSSL error queue, where each item is a tuple (lib, function, reason). Here lib, function and reason are all strings, describing where and what the problem is. See err(3) for more information.
This exception matches the error return code SSL_ERROR_ZERO_RETURN, and is raised when the SSL Connection has been closed. In SSL 3.0 and TLS 1.0, this only occurs if a closure alert has occurred in the protocol, i.e. the connection has been closed cleanly. Note that this does not necessarily mean that the transport layer (e.g. a socket) has been closed.
It may seem a little strange that this is an exception, but it does match an SSL_ERROR code, and is very convenient.
The operation did not complete; the same I/O method should be called again later, with the same arguments. Any I/O method can lead to this since new handshakes can occur at any time.
The wanted read is for dirty data sent over the network, not the clean data inside the tunnel. For a socket based SSL connection, read means data coming at us over the network. Until that read succeeds, the attempted OpenSSL.SSL.Connection.recv(), OpenSSL.SSL.Connection.send(), or OpenSSL.SSL.Connection.do_handshake() is prevented or incomplete. You probably want to select() on the socket before trying again.
See WantReadError. The socket send buffer may be too full to write more data.
The operation did not complete because an application callback has asked to be called again. The I/O method should be called again later, with the same arguments.
Note
This won’t occur in this version, as there are no such callbacks in this version.
The SysCallError occurs when there’s an I/O error and OpenSSL’s error queue does not contain any information. This can mean two things: An error in the transport protocol, or an end of file that violates the protocol. The parameter to the exception is always a pair (errnum, errstr).
Context objects have the following methods:
Check if the private key (loaded with use_privatekey()) matches the certificate (loaded with use_certificate()). Returns None if they match, raises Error otherwise.
Retrieve application data as set by set_app_data().
Retrieve the certificate store (a X509Store object) that the context uses. This can be used to add “trusted” certificates without using the. load_verify_locations() method.
Retrieve session timeout, as set by set_timeout(). The default is 300 seconds.
Retrieve the Context object’s verify depth, as set by set_verify_depth().
Retrieve the Context object’s verify mode, as set by set_verify().
Read a file with PEM-formatted certificates that will be sent to the client when requesting a client certificate.
Replace the current list of preferred certificate signers that would be sent to the client when requesting a client certificate with the certificate_authorities sequence of OpenSSL.crypto.X509Name‘s.
New in version 0.10.
Extract a OpenSSL.crypto.X509Name from the certificate_authority OpenSSL.crypto.X509 certificate and add it to the list of preferred certificate signers sent to the client when requesting a client certificate.
New in version 0.10.
Specify where CA certificates for verification purposes are located. These are trusted certificates. Note that the certificates have to be in PEM format. If capath is passed, it must be a directory prepared using the c_rehash tool included with OpenSSL. Either, but not both, of pemfile or capath may be None.
Specify that the platform provided CA certificates are to be used for verification purposes. This method may not work properly on OS X.
Load parameters for Ephemeral Diffie-Hellman from dhfile.
Associate data with this Context object. data can be retrieved later using the get_app_data() method.
Set the list of ciphers to be used in this context. See the OpenSSL manual for more information (e.g. ciphers(1))
Set the information callback to callback. This function will be called from time to time during SSL handshakes.
callback should take three arguments: a Connection object and two integers. The first integer specifies where in the SSL handshake the function was called, and the other the return code from a (possibly failed) internal function call.
Add SSL options. Options you have set before are not cleared! This method should be used with the OP_* constants.
Add SSL mode. Modes you have set before are not cleared! This method should be used with the MODE_* constants.
Set the passphrase callback to callback. This function will be called when a private key with a passphrase is loaded. callback must accept three positional arguments. First, an integer giving the maximum length of the passphrase it may return. If the returned passphrase is longer than this, it will be truncated. Second, a boolean value which will be true if the user should be prompted for the passphrase twice and the callback should verify that the two values supplied are equal. Third, the value given as the userdata parameter to set_passwd_cb(). If an error occurs, callback should return a false value (e.g. an empty string).
Set the behavior of the session cache used by all connections using this Context. The previously set mode is returned. See SESS_CACHE_* for details about particular modes.
New in version 0.14.
Get the current session cache mode.
New in version 0.14.
Set the context name within which a session can be reused for this Context object. This is needed when doing session resumption, because there is no way for a stored session to know which Context object it is associated with. name may be any binary data.
Set the timeout for newly created sessions for this Context object to timeout. timeout must be given in (whole) seconds. The default value is 300 seconds. See the OpenSSL manual for more information (e.g. SSL_CTX_set_timeout(3)).
Set the verification flags for this Context object to mode and specify that callback should be used for verification callbacks. mode should be one of VERIFY_NONE and VERIFY_PEER. If VERIFY_PEER is used, mode can be OR:ed with VERIFY_FAIL_IF_NO_PEER_CERT and VERIFY_CLIENT_ONCE to further control the behaviour.
callback should take five arguments: A Connection object, an X509 object, and three integer variables, which are in turn potential error number, error depth and return code. callback should return true if verification passes and false otherwise.
Set the maximum depth for the certificate chain verification that shall be allowed for this Context object.
Use the certificate cert which has to be a X509 object.
Adds the certificate cert, which has to be a X509 object, to the certificate chain presented together with the certificate.
Load a certificate chain from file which must be PEM encoded.
Use the private key pkey which has to be a PKey object.
Load the first certificate found in file. The certificate must be in the format specified by format, which is either FILETYPE_PEM or FILETYPE_ASN1. The default is FILETYPE_PEM.
Load the first private key found in file. The private key must be in the format specified by format, which is either FILETYPE_PEM or FILETYPE_ASN1. The default is FILETYPE_PEM.
Specify a one-argument callable to use as the TLS extension server name callback. When a connection using the server name extension is made using this context, the callback will be invoked with the Connection instance.
New in version 0.13.
Session objects have no methods.
Connection objects¶Connection objects have the following methods:
Call the accept() method of the underlying socket and set up SSL on the returned socket, using the Context object supplied to this Connection object at creation. Returns a pair (conn, address). where conn is the new Connection object created, and address is as returned by the socket’s accept().
Call the bind() method of the underlying socket.
Call the close() method of the underlying socket. Note: If you want correct SSL closure, you need to call the shutdown() method first.
Call the connect() method of the underlying socket and set up SSL on the socket, using the Context object supplied to this Connection object at creation.
Call the connect_ex() method of the underlying socket and set up SSL on the socket, using the Context object supplied to this Connection object at creation. Note that if the connect_ex() method of the socket doesn’t return 0, SSL won’t be initialized.
Perform an SSL handshake (usually called after renegotiate() or one of set_accept_state() or set_accept_state()). This can raise the same exceptions as send() and recv().
Retrieve the file descriptor number for the underlying socket.
Call the listen() method of the underlying socket.
Retrieve application data as set by set_app_data().
Retrieve the list of ciphers used by the Connection object. WARNING: This API has changed. It used to take an optional parameter and just return a string, but not it returns the entire list in one go.
Retrieve the list of preferred client certificate issuers sent by the server as OpenSSL.crypto.X509Name objects.
If this is a client Connection, the list will be empty until the connection with the server is established.
If this is a server Connection, return the list of certificate authorities that will be sent or has been sent to the client, as controlled by this Connection‘s Context.
New in version 0.10.
Retrieve the Context object associated with this Connection.
Specify a replacement Context object for this Connection.
Retrieve the other side’s certificate (if any)
Retrieve the tuple of the other side’s certificate chain (if any)
Call the getpeername() method of the underlying socket.
Call the getsockname() method of the underlying socket.
Call the getsockopt() method of the underlying socket.
Retrieve the number of bytes that can be safely read from the SSL buffer (not the underlying transport buffer).
Receive data from the Connection. The return value is a string representing the data received. The maximum amount of data to be received at once, is specified by bufsize.
If the Connection was created with a memory BIO, this method can be used to add bytes to the read end of that memory BIO. The Connection can then read the bytes (for example, in response to a call to recv()).
Renegotiate the SSL session. Call this if you wish to change cipher suites or anything like that.
Send the string data to the Connection.
If the Connection was created with a memory BIO, this method can be used to read bytes from the write end of that memory BIO. Many Connection methods will add bytes which must be read in this manner or the buffer will eventually fill up and the Connection will be able to take no further actions.
Send all of the string data to the Connection. This calls send() repeatedly until all data is sent. If an error occurs, it’s impossible to tell how much data has been sent.
Set the connection to work in server mode. The handshake will be handled automatically by read/write.
Associate data with this Connection object. data can be retrieved later using the get_app_data() method.
Set the connection to work in client mode. The handshake will be handled automatically by read/write.
Call the setblocking() method of the underlying socket.
Call the setsockopt() method of the underlying socket.
Send the shutdown message to the Connection. Returns true if the shutdown message exchange is completed and false otherwise (in which case you call recv() or send() when the connection becomes readable/writeable.
Get the shutdown state of the Connection. Returns a bitvector of either or both of SENT_SHUTDOWN and RECEIVED_SHUTDOWN.
Set the shutdown state of the Connection. state is a bitvector of either or both of SENT_SHUTDOWN and RECEIVED_SHUTDOWN.
Call the shutdown() method of the underlying socket.
If the Connection was created with a memory BIO, this method can be used to indicate that end of file has been reached on the read end of that memory BIO.
Retrieve a verbose string detailing the state of the Connection.
Retrieve the random value used with the client hello message.
Retrieve the random value used with the server hello message.
Retrieve the value of the master key for this session.
Checks if more data has to be read from the transport layer to complete an operation.
Checks if there is data to write to the transport layer to complete an operation.
Specify the byte string to send as the server name in the client hello message.
New in version 0.13.
Get the value of the server name received in the client hello message.
New in version 0.13.
Get a Session instance representing the SSL session in use by the connection, or None if there is no session.
New in version 0.14.
Set a new SSL session (using a Session instance) to be used by the connection.
New in version 0.14.
Footnotes
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4