Skip to content

Commit 17459d6

Browse files
authored
{Misc.} Remove unreachable code for creating SSL context (#31919)
1 parent 204d34b commit 17459d6

File tree

4 files changed

+2
-29
lines changed

4 files changed

+2
-29
lines changed

src/azure-cli-core/azure/cli/core/util.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,12 +1164,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
11641164

11651165

11661166
def _ssl_context():
1167-
if sys.version_info < (3, 4) or (in_cloud_console() and platform.system() == 'Windows'):
1168-
try:
1169-
return ssl.SSLContext(ssl.PROTOCOL_TLS) # added in python 2.7.13 and 3.6
1170-
except AttributeError:
1171-
return ssl.SSLContext(ssl.PROTOCOL_TLSv1)
1172-
11731167
return ssl.create_default_context()
11741168

11751169

src/azure-cli/azure/cli/command_modules/acr/helm.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from knack.util import CLIError
1111
from knack.log import get_logger
1212

13-
from azure.cli.core.util import in_cloud_console, user_confirmation
13+
from azure.cli.core.util import user_confirmation
1414

1515
from ._docker_utils import (
1616
get_access_credentials,
@@ -366,15 +366,7 @@ def _get_helm_package_name(client_version):
366366

367367

368368
def _ssl_context():
369-
import sys
370369
import ssl
371-
372-
if sys.version_info < (3, 4) or (in_cloud_console() and platform.system() == 'Windows'):
373-
try:
374-
return ssl.SSLContext(ssl.PROTOCOL_TLS) # added in python 2.7.13 and 3.6
375-
except AttributeError:
376-
return ssl.SSLContext(ssl.PROTOCOL_TLSv1)
377-
378370
return ssl.create_default_context()
379371

380372

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,13 +2218,6 @@ def k8s_install_kubelogin(cmd, client_version='latest', install_location=None, s
22182218

22192219

22202220
def _ssl_context():
2221-
if sys.version_info < (3, 4) or (in_cloud_console() and platform.system() == 'Windows'):
2222-
try:
2223-
# added in python 2.7.13 and 3.6
2224-
return ssl.SSLContext(ssl.PROTOCOL_TLS)
2225-
except AttributeError:
2226-
return ssl.SSLContext(ssl.PROTOCOL_TLSv1)
2227-
22282221
return ssl.create_default_context()
22292222

22302223

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
from azure.cli.core.commands.client_factory import get_mgmt_service_client
4343
from azure.cli.core.commands import LongRunningOperation
44-
from azure.cli.core.util import in_cloud_console, shell_safe_json_parse, open_page_in_browser, get_json_object, \
44+
from azure.cli.core.util import shell_safe_json_parse, open_page_in_browser, get_json_object, \
4545
ConfiguredDefaultSetter, sdk_no_wait
4646
from azure.cli.core.util import get_az_user_agent, send_raw_request, get_file_json
4747
from azure.cli.core.profiles import ResourceType, get_sdk
@@ -2676,12 +2676,6 @@ def _redact_storage_accounts(properties):
26762676

26772677

26782678
def _ssl_context():
2679-
if sys.version_info < (3, 4) or (in_cloud_console() and sys.platform.system() == 'Windows'):
2680-
try:
2681-
return ssl.SSLContext(ssl.PROTOCOL_TLS) # added in python 2.7.13 and 3.6
2682-
except AttributeError:
2683-
return ssl.SSLContext(ssl.PROTOCOL_TLSv1)
2684-
26852679
return ssl.create_default_context()
26862680

26872681

0 commit comments

Comments
 (0)