Skip to content

Revert "[ServiceBus/EventHub] move async ssl opts to transport constructor" #37671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
7 changes: 1 addition & 6 deletions sdk/eventhub/azure-eventhub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
## 5.12.2 (2024-10-02)

### Bugs Fixed

- Fixed a bug where creating the SSL context in the async clients was making a blocking call outside of the constructor.([#37246](https://github.com/Azure/azure-sdk-for-python/issues/37246))

### Other Changes

- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398))
- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398))

## 5.12.1 (2024-06-11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,23 @@ def __init__(
self.sslopts = ssl_opts
self.network_trace_params = kwargs.get('network_trace_params')
self._use_tls = use_tls
try:
self.sslopts = self._build_ssl_opts(self.sslopts)
except FileNotFoundError as exc:
# FileNotFoundError does not have missing filename info, so adding it below.
# Assuming that this must be ca_certs, since this is the only file path that
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
# For uamqp exception parity.
exc.filename = self.sslopts
raise exc

async def connect(self):
try:
# are we already connected?
if self.connected:
return
try:
# Building ssl opts here instead of constructor, so that invalid cert error is raised
# when client is connecting, rather then during creation. For uamqp exception parity.
self.sslopts = self._build_ssl_opts(self.sslopts)
except FileNotFoundError as exc:
# FileNotFoundError does not have missing filename info, so adding it below.
# Assuming that this must be ca_certs, since this is the only file path that
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
# For uamqp exception parity. Remove later when resolving issue #27128.
exc.filename = self.sslopts
raise exc
self.reader, self.writer = await asyncio.open_connection(
host=self.host,
port=self.port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,11 @@ async def on_error(partition_context, error):
fully_qualified_namespace=live_eventhub["hostname"],
eventhub_name=live_eventhub["event_hub"],
credential=azure_credential,
connection_verify="fakecert.pem",
connection_verify="cacert.pem",
uamqp_transport=uamqp_transport,
)

# TODO: this seems like a bug from uamqp, should be ConnectError?
async with producer_client:
with pytest.raises(EventHubError):
await producer_client.create_batch(partition_id="0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,11 @@ def on_error(partition_context, error):
fully_qualified_namespace=live_eventhub["hostname"],
eventhub_name=live_eventhub["event_hub"],
credential=azure_credential,
connection_verify="fakecert.pem",
connection_verify="cacert.pem",
uamqp_transport=uamqp_transport,
)

# TODO: this seems like a bug from uamqp, should be ConnectError?
with producer_client:
with pytest.raises(EventHubError):
producer_client.create_batch(partition_id="0")
Expand Down
2 changes: 0 additions & 2 deletions sdk/servicebus/azure-servicebus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

### Bugs Fixed

- Fixed a bug where creating the SSL context in the async clients was making a blocking call outside of the constructor.([#37246](https://github.com/Azure/azure-sdk-for-python/issues/37246))

### Other Changes

## 7.12.3 (2024-09-19)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,23 @@ def __init__(
self.sslopts = ssl_opts
self.network_trace_params = kwargs.get('network_trace_params')
self._use_tls = use_tls
try:
self.sslopts = self._build_ssl_opts(self.sslopts)
except FileNotFoundError as exc:
# FileNotFoundError does not have missing filename info, so adding it below.
# Assuming that this must be ca_certs, since this is the only file path that
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
# For uamqp exception parity.
exc.filename = self.sslopts
raise exc

async def connect(self):
try:
# are we already connected?
if self.connected:
return
try:
# Building ssl opts here instead of constructor, so that invalid cert error is raised
# when client is connecting, rather then during creation. For uamqp exception parity.
self.sslopts = self._build_ssl_opts(self.sslopts)
except FileNotFoundError as exc:
# FileNotFoundError does not have missing filename info, so adding it below.
# Assuming that this must be ca_certs, since this is the only file path that
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
# For uamqp exception parity. Remove later when resolving issue #27128.
exc.filename = self.sslopts
raise exc
self.reader, self.writer = await asyncio.open_connection(
host=self.host,
port=self.port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,8 @@ async def test_custom_endpoint_connection_verify_exception_async(self,
# invalid cert file to connection_verify should fail
client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport)
async with client:
sender = client.get_queue_sender(servicebus_queue.name)
with pytest.raises(ServiceBusError):
async with sender:
async with client.get_queue_sender(servicebus_queue.name) as sender:
await sender.send_messages(ServiceBusMessage("foo"))

# Skipping on OSX uamqp - it's raising an Authentication/TimeoutError
Expand Down
3 changes: 1 addition & 2 deletions sdk/servicebus/azure-servicebus/tests/test_sb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,8 @@ def test_custom_endpoint_connection_verify_exception(self,
# invalid cert file to connection_verify should fail
client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport)
with client:
sender = client.get_queue_sender(servicebus_queue.name)
with pytest.raises(ServiceBusError):
with sender:
with client.get_queue_sender(servicebus_queue.name) as sender:
sender.send_messages(ServiceBusMessage("foo"))

# Skipping on OSX uamqp - it's raising an Authentication/TimeoutError
Expand Down
Loading