diff --git a/botocore/client.py b/botocore/client.py index ee1500a1b8..6bfb538a12 100644 --- a/botocore/client.py +++ b/botocore/client.py @@ -11,6 +11,7 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. import logging +import os import warnings from botocore import waiter, xform_name @@ -609,13 +610,17 @@ def _create_endpoint( if endpoint_url is None: sslCommonName = resolved.get('sslCommonName') hostname = resolved.get('hostname') - if sslCommonName is not None: + disable = ensure_boolean( + os.environ.get('BOTO_EXPERIMENTAL__DISABLE_COMMONNAME', '') + ) + if not disable and sslCommonName is not None: warnings.warn( f'The {service_name} client is currently using a ' f'deprecated endpoint: {sslCommonName}. In the next ' f'minor version this will be moved to {hostname}. ' 'See https://github.com/boto/botocore/issues/2376 ' 'for more details.', + category=FutureWarning, ) hostname = sslCommonName endpoint_url = self._make_url( diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 071e1bf061..219433fe3a 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -1610,7 +1610,7 @@ def test_client_close_context_manager(self): def test_sslCommonName_warning(self): creator = self.create_client_creator() self.endpoint_data['sslCommonName'] = 'bar' - with self.assertWarns(UserWarning) as warning: + with self.assertWarns(FutureWarning) as warning: creator.create_client( 'myservice', 'us-west-2', credentials=self.credentials )