🌐
GitHub
github.com › python › cpython › blob › main › Lib › ssl.py
cpython/Lib/ssl.py at main · python/cpython
All Python stdlib modules shall use this function to create SSLContext · objects in order to keep common settings in one place. The configuration · is less restrict than create_default_context()'s to increase backward · compatibility. """ if not isinstance(purpose, _ASN1Object): raise TypeError(purpose) · # SSLContext sets OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION, # OP_CIPHER_SERVER_PREFERENCE, OP_SINGLE_DH_USE and OP_SINGLE_ECDH_USE ·
Author   python
🌐
Beautiful Soup
tedboy.github.io › python_stdlib › generated › generated › ssl.SSLContext.get_ca_certs.html
ssl.SSLContext.get_ca_certs — Python Standard Library
ssl.SSLContext » · ssl.SSLContext.get_ca_certs · View page source · SSLContext.get_ca_certs(binary_form=False) → list of loaded certificate¶ · Returns a list of dicts with information of loaded CA certs. If the optional argument is True, returns a DER-encoded copy of the CA certificate.
🌐
GitHub
github.com › ramikg › ssl-context-configurator
GitHub - ramikg/ssl-context-configurator: Configure Python SSLContext objects in a hacky way
Unfortunately, Python does not allow the full SSL/TLS configuration power offered by OpenSSL. Through some ctypes fun, this library finds the underlying SSL_CTX C object in memory, and configures it by calling the OpenSSL function SSL_CONF_cmd.
Author   ramikg
🌐
GitHub
github.com › python › cpython › blob › main › Modules › _ssl.c
cpython/Modules/_ssl.c at main · python/cpython
Return search paths and environment vars that are used by SSLContext's set_default_verify_paths() to load default CAs.
Author   python
🌐
GitHub
github.com › encode › httpx › issues › 924
How can I use a custom SSLContext / PyOpenSSLContext when creating a Client? · Issue #924 · encode/httpx
May 2, 2020 - @sethmlarson suggests httpx.Client(verify=ssl_context) in 469, which looked similar to my use-case but not identical.
Author   kafonek
🌐
GitHub
github.com › python › cpython › blob › main › Lib › test › test_ssl.py
cpython/Lib/test/test_ssl.py at main · python/cpython
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") · @unittest.skipUnless(PY_SSL_DEFAULT_CIPHERS == 1, "Test applies only to Python default ciphers") def test_python_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ciphers = ctx.get_ciphers() for suite in ciphers: name = suite['name'] self.assertNotIn("PSK", name) self.assertNotIn("SRP", name) self.assertNotIn("MD5", name) self.assertNotIn("RC4", name) self.assertNotIn("3DES", name) ·
Author   python
🌐
Wolfssl
wolfssl.github.io › wolfssl-py
wolfssl Python 3.14.0-1 documentation
An SSLContext holds various SSL-related configuration options and data, such as certificates and possibly a private key. ... Whether to try to verify other peers’ certificates and how to behave if verification fails. This attribute must be one of CERT_NONE, CERT_OPTIONAL or CERT_REQUIRED. ...
🌐
GitHub
github.com › psf › requests › issues › 2118
Let the user provide an SSLContext object · Issue #2118 · psf/requests
July 2, 2014 - The requests library seems to grow more and more keyword arguments to try to provide all of the flexibility that SSL users need. As of Python 3.2, the Standard Library now offers a different approach: an SSLContext that can accept settings for TLS protocol version, CA certificate list, identity certificate, secret key, allowable cipher list, Diffie-Hellman parameters, server-name callback function, whether to verify server hostnames, and so forth.
Author   brandon-rhodes
Find elsewhere
🌐
Python
docs.python.org › 3 › library › ssl.html
ssl — TLS/SSL wrapper for socket objects — Python 3.14.4 ...
Return a new SSLContext object with default settings for the given purpose. The settings are chosen by the ssl module, and usually represent a higher security level than when calling the SSLContext constructor directly.
🌐
GitHub
github.com › pyca › pyopenssl › blob › main › src › OpenSSL › SSL.py
pyopenssl/src/OpenSSL/SSL.py at main · pyca/pyopenssl
August 24, 2022 - A Python wrapper around the OpenSSL library. Contribute to pyca/pyopenssl development by creating an account on GitHub.
Author   pyca
🌐
GitHub
gist.github.com › oborichkin › d8d0c7823fd6db3abeb25f69352a5299
Simple TLS client and server on python · GitHub
import socket import ssl import time HOST = "127.0.0.1" PORT = 8443 if __name__ == "__main__": context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) context.load_cert_chain(certfile="/path/to/certfile", keyfile="/path/to/keyfile") context.load_verify_locations(cafile="/path/to/certfile") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client = context.wrap_socket(s, server_hostname=HOST) s.close() client.connect((HOST, PORT)) while True: client.sendall("Hello World!".encode("utf-8")) time.sleep(1)
🌐
GitHub
github.com › urllib3 › urllib3 › blob › main › src › urllib3 › util › ssl_.py
urllib3/src/urllib3/util/ssl_.py at main · urllib3/urllib3
``ssl.VERIFY_X509_PARTIAL_CHAIN`` and ``ssl.VERIFY_X509_STRICT`` for Python 3.13+. :returns: Constructed SSLContext object with specified options · :rtype: SSLContext · """ if SSLContext is None: raise TypeError("Can't create an SSLContext object without an ssl module") ·
Author   urllib3
🌐
GitHub
github.com › blackberry › Python › blob › master › Python-3 › Lib › ssl.py
Python/Python-3/Lib/ssl.py at master · blackberry/Python
"""An SSLContext holds various SSL-related configuration options and · data, such as certificates and possibly a private key.""" · __slots__ = ('protocol',) · def __new__(cls, protocol, *args, **kwargs): return _SSLContext.__new__(cls, protocol) ·
Author   blackberry
🌐
GitHub
github.com › vmware › pyvmomi › issues › 1057
Python 3.12 issue with wrap_socket (deprecated in 3.7) · Issue #1057 · vmware/pyvmomi
November 21, 2023 - Remove the ssl.wrap_socket() function, deprecated in Python 3.7: instead, create a ssl.SSLContext object and call its ssl.SSLContext.wrap_socket method. Any package that still uses ssl.wrap_socket() is broken and insecure. The function neither sends a SNI TLS extension nor validates server hostname.
Author   ekrichbaum
🌐
GitHub
github.com › codeborne › play › blob › master › python › Lib › ssl.py
play/python/Lib/ssl.py at master · codeborne/play
All Python stdlib modules shall use this function to create SSLContext · objects in order to keep common settings in one place. The configuration · is less restrict than create_default_context()'s to increase backward · compatibility. · """ · if not isinstance(purpose, _ASN1Object): · raise TypeError(purpose) · · context = SSLContext(protocol) · # SSLv2 considered harmful.
Author   codeborne
🌐
CodeQL
codeql.github.com › codeql-query-help › python › py-insecure-protocol
Use of insecure SSL/TLS version - CodeQL - GitHub
The following code illustrates how to use flags (available since Python 3.2) or the `minimum_version` field (favored since Python 3.7) to restrict the protocols accepted when creating a connection. import ssl # Using flags to restrict the protocol context = ssl.SSLContext() context.options ...
🌐
GitHub
github.com › wdk-docs › python-documentation › blob › master › docs › library › ssl.rst
python-documentation/docs/library/ssl.rst at master · wdk-docs/python-documentation
For more sophisticated applications, the :class:`ssl.SSLContext` class helps manage settings and certificates, which can then be inherited by SSL sockets created through the :meth:`SSLContext.wrap_socket` method.
Author   wdk-docs