Skip to content

Commit 8d74c96

Browse files
authored
Revert "[ServiceBus/EventHub] move async ssl opts to transport constructor (#…" (#37671)
This reverts commit 295c432.
1 parent dba25c1 commit 8d74c96

File tree

8 files changed

+29
-32
lines changed

8 files changed

+29
-32
lines changed

sdk/eventhub/azure-eventhub/CHANGELOG.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
## 5.12.2 (2024-10-02)
44

55
### Bugs Fixed
6-
7-
- 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))
8-
9-
### Other Changes
10-
11-
- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398))
6+
- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398))
127

138
## 5.12.1 (2024-06-11)
149

sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,23 @@ def __init__(
262262
self.sslopts = ssl_opts
263263
self.network_trace_params = kwargs.get('network_trace_params')
264264
self._use_tls = use_tls
265-
try:
266-
self.sslopts = self._build_ssl_opts(self.sslopts)
267-
except FileNotFoundError as exc:
268-
# FileNotFoundError does not have missing filename info, so adding it below.
269-
# Assuming that this must be ca_certs, since this is the only file path that
270-
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
271-
# For uamqp exception parity.
272-
exc.filename = self.sslopts
273-
raise exc
274265

275266
async def connect(self):
276267
try:
277268
# are we already connected?
278269
if self.connected:
279270
return
271+
try:
272+
# Building ssl opts here instead of constructor, so that invalid cert error is raised
273+
# when client is connecting, rather then during creation. For uamqp exception parity.
274+
self.sslopts = self._build_ssl_opts(self.sslopts)
275+
except FileNotFoundError as exc:
276+
# FileNotFoundError does not have missing filename info, so adding it below.
277+
# Assuming that this must be ca_certs, since this is the only file path that
278+
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
279+
# For uamqp exception parity. Remove later when resolving issue #27128.
280+
exc.filename = self.sslopts
281+
raise exc
280282
self.reader, self.writer = await asyncio.open_connection(
281283
host=self.host,
282284
port=self.port,

sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,11 @@ async def on_error(partition_context, error):
503503
fully_qualified_namespace=live_eventhub["hostname"],
504504
eventhub_name=live_eventhub["event_hub"],
505505
credential=azure_credential,
506-
connection_verify="fakecert.pem",
506+
connection_verify="cacert.pem",
507507
uamqp_transport=uamqp_transport,
508508
)
509509

510+
# TODO: this seems like a bug from uamqp, should be ConnectError?
510511
async with producer_client:
511512
with pytest.raises(EventHubError):
512513
await producer_client.create_batch(partition_id="0")

sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,11 @@ def on_error(partition_context, error):
444444
fully_qualified_namespace=live_eventhub["hostname"],
445445
eventhub_name=live_eventhub["event_hub"],
446446
credential=azure_credential,
447-
connection_verify="fakecert.pem",
447+
connection_verify="cacert.pem",
448448
uamqp_transport=uamqp_transport,
449449
)
450450

451+
# TODO: this seems like a bug from uamqp, should be ConnectError?
451452
with producer_client:
452453
with pytest.raises(EventHubError):
453454
producer_client.create_batch(partition_id="0")

sdk/servicebus/azure-servicebus/CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
### Bugs Fixed
1010

11-
- 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))
12-
1311
### Other Changes
1412

1513
## 7.12.3 (2024-09-19)

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,23 @@ def __init__(
262262
self.sslopts = ssl_opts
263263
self.network_trace_params = kwargs.get('network_trace_params')
264264
self._use_tls = use_tls
265-
try:
266-
self.sslopts = self._build_ssl_opts(self.sslopts)
267-
except FileNotFoundError as exc:
268-
# FileNotFoundError does not have missing filename info, so adding it below.
269-
# Assuming that this must be ca_certs, since this is the only file path that
270-
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
271-
# For uamqp exception parity.
272-
exc.filename = self.sslopts
273-
raise exc
274265

275266
async def connect(self):
276267
try:
277268
# are we already connected?
278269
if self.connected:
279270
return
271+
try:
272+
# Building ssl opts here instead of constructor, so that invalid cert error is raised
273+
# when client is connecting, rather then during creation. For uamqp exception parity.
274+
self.sslopts = self._build_ssl_opts(self.sslopts)
275+
except FileNotFoundError as exc:
276+
# FileNotFoundError does not have missing filename info, so adding it below.
277+
# Assuming that this must be ca_certs, since this is the only file path that
278+
# users can pass in (`connection_verify` in the EH/SB clients) through sslopts above.
279+
# For uamqp exception parity. Remove later when resolving issue #27128.
280+
exc.filename = self.sslopts
281+
raise exc
280282
self.reader, self.writer = await asyncio.open_connection(
281283
host=self.host,
282284
port=self.port,

sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,8 @@ async def test_custom_endpoint_connection_verify_exception_async(self,
672672
# invalid cert file to connection_verify should fail
673673
client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport)
674674
async with client:
675-
sender = client.get_queue_sender(servicebus_queue.name)
676675
with pytest.raises(ServiceBusError):
677-
async with sender:
676+
async with client.get_queue_sender(servicebus_queue.name) as sender:
678677
await sender.send_messages(ServiceBusMessage("foo"))
679678

680679
# Skipping on OSX uamqp - it's raising an Authentication/TimeoutError

sdk/servicebus/azure-servicebus/tests/test_sb_client.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,8 @@ def test_custom_endpoint_connection_verify_exception(self,
700700
# invalid cert file to connection_verify should fail
701701
client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport)
702702
with client:
703-
sender = client.get_queue_sender(servicebus_queue.name)
704703
with pytest.raises(ServiceBusError):
705-
with sender:
704+
with client.get_queue_sender(servicebus_queue.name) as sender:
706705
sender.send_messages(ServiceBusMessage("foo"))
707706

708707
# Skipping on OSX uamqp - it's raising an Authentication/TimeoutError

0 commit comments

Comments
 (0)