Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@ There are different *mutually exclusive* ways of configuring TLS/SSL encryption
* or set :ref:`ssl-context-ref` to gain full control (and responsibility) over the TLS configuration.
* or set ``encrypted=False`` (default) to disable TLS.

All options except for configuring a custom :ref:`ssl-context-ref` will check the
environment variable ``SSLKEYLOGFILE``.
If the variable is set, it's value will be assinged to
:attr:`ssl.SSLContext.keylog_filename` to enable keyfile logging.


Driver Object Lifetime
Expand Down
8 changes: 8 additions & 0 deletions src/neo4j/_async/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from __future__ import annotations

import os

from .. import _typing as t
from .._async_compat.concurrency import AsyncLock
from .._conf import (
Expand Down Expand Up @@ -154,6 +156,12 @@ async def get_ssl_context(self) -> ssl.SSLContext | None:
# https://docs.python.org/3.10/library/ssl.html#protocol-versions
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2

# Follow Python's `create_default_context` and respect the
# `SSLKEYLOGFILE` environment variable for key logging if present.
ssl_keylog_file = os.getenv("SSLKEYLOGFILE")
if ssl_keylog_file:
ssl_context.keylog_filename = ssl_keylog_file

if isinstance(self.trusted_certificates, TrustAll):
# trust any certificate
ssl_context.check_hostname = False
Expand Down
8 changes: 8 additions & 0 deletions src/neo4j/_sync/config.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading