diff --git a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache index fefd5e2af81d..b83220e19062 100644 --- a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache @@ -69,6 +69,8 @@ class RESTClientObject: self.ssl_context.check_hostname = False self.ssl_context.verify_mode = ssl.CERT_NONE + if configuration.disable_strict_ssl_verification: + self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers diff --git a/modules/openapi-generator/src/main/resources/python/configuration.mustache b/modules/openapi-generator/src/main/resources/python/configuration.mustache index 81d1d8da60d9..c47d8bbb6f8e 100644 --- a/modules/openapi-generator/src/main/resources/python/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/python/configuration.mustache @@ -196,6 +196,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. {{#asyncio}} @@ -375,6 +376,7 @@ conf = {{{packageName}}}.Configuration( socket_options: Optional[Any]=None, datetime_format: str="{{{datetimeFormat}}}", date_format: str="{{{dateFormat}}}", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -454,6 +456,7 @@ conf = {{{packageName}}}.Configuration( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/modules/openapi-generator/src/main/resources/python/httpx/rest.mustache b/modules/openapi-generator/src/main/resources/python/httpx/rest.mustache index fc20b48351b7..ddad3c3a7bb2 100644 --- a/modules/openapi-generator/src/main/resources/python/httpx/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/httpx/rest.mustache @@ -62,6 +62,8 @@ class RESTClientObject: self.ssl_context.check_hostname = False self.ssl_context.verify_mode = ssl.CERT_NONE + if configuration.disable_strict_ssl_verification: + self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers diff --git a/modules/openapi-generator/src/main/resources/python/rest.mustache b/modules/openapi-generator/src/main/resources/python/rest.mustache index 5f56a2d60b32..3f55d717593e 100644 --- a/modules/openapi-generator/src/main/resources/python/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/rest.mustache @@ -134,6 +134,16 @@ class RESTClientObject: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py index f2411fe6bd9d..bd86c247aa8f 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py @@ -163,6 +163,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | urllib3.util.retry.Retry - Retry configuration. @@ -235,6 +236,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -305,6 +307,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py index 9a0c6d4de785..95883b351247 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py @@ -144,6 +144,13 @@ def __init__(self, configuration) -> None: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries diff --git a/samples/client/echo_api/python/openapi_client/configuration.py b/samples/client/echo_api/python/openapi_client/configuration.py index f2411fe6bd9d..bd86c247aa8f 100644 --- a/samples/client/echo_api/python/openapi_client/configuration.py +++ b/samples/client/echo_api/python/openapi_client/configuration.py @@ -163,6 +163,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | urllib3.util.retry.Retry - Retry configuration. @@ -235,6 +236,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -305,6 +307,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/client/echo_api/python/openapi_client/rest.py b/samples/client/echo_api/python/openapi_client/rest.py index 77b4fe56053a..51e98f696628 100644 --- a/samples/client/echo_api/python/openapi_client/rest.py +++ b/samples/client/echo_api/python/openapi_client/rest.py @@ -144,6 +144,16 @@ def __init__(self, configuration) -> None: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py index b99862654f04..6564d5e79dbc 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py @@ -160,6 +160,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | urllib3.util.retry.Retry - Retry configuration. @@ -215,6 +216,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -285,6 +287,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py index c6da043e386b..e947ea86fa98 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py @@ -143,6 +143,13 @@ def __init__(self, configuration) -> None: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/configuration.py index 38f5a69aeef3..fd6a6463950c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/configuration.py @@ -167,6 +167,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration. @@ -306,6 +307,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -380,6 +382,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py index 374aeeb993fa..f5413c2384c5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py @@ -78,6 +78,8 @@ def __init__(self, configuration) -> None: self.ssl_context.check_hostname = False self.ssl_context.verify_mode = ssl.CERT_NONE + if configuration.disable_strict_ssl_verification: + self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/configuration.py index cefa6fa3a1f9..bdfaa6e15fc5 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/configuration.py @@ -165,6 +165,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int - Retry configuration. @@ -292,6 +293,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -366,6 +368,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/rest.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/rest.py index e1d0094b6c56..19ceb61a4cd1 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/rest.py @@ -71,6 +71,8 @@ def __init__(self, configuration) -> None: self.ssl_context.check_hostname = False self.ssl_context.verify_mode = ssl.CERT_NONE + if configuration.disable_strict_ssl_verification: + self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py index cefa6fa3a1f9..bdfaa6e15fc5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py @@ -165,6 +165,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int - Retry configuration. @@ -292,6 +293,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -366,6 +368,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/rest.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/rest.py index e1d0094b6c56..19ceb61a4cd1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/rest.py @@ -71,6 +71,8 @@ def __init__(self, configuration) -> None: self.ssl_context.check_hostname = False self.ssl_context.verify_mode = ssl.CERT_NONE + if configuration.disable_strict_ssl_verification: + self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py index 7e9c9d177921..c7ab3925505c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py @@ -169,6 +169,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | urllib3.util.retry.Retry - Retry configuration. @@ -300,6 +301,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -375,6 +377,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py index 8affe12ad0a2..6210cf66fb8a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py @@ -143,6 +143,13 @@ def __init__(self, configuration) -> None: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries diff --git a/samples/openapi3/client/petstore/python/petstore_api/configuration.py b/samples/openapi3/client/petstore/python/petstore_api/configuration.py index 3fdb5641b4d3..0fd9717a4ea1 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python/petstore_api/configuration.py @@ -169,6 +169,7 @@ class Configuration: values before. :param verify_ssl: bool - Set this to false to skip verifying SSL certificate when calling API from https server. + :param disable_strict_ssl_verification: bool - Set this to true to disable strict X.509 certificate verification. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. :param retries: int | urllib3.util.retry.Retry - Retry configuration. @@ -300,6 +301,7 @@ def __init__( socket_options: Optional[Any]=None, datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z", date_format: str="%Y-%m-%d", + disable_strict_ssl_verification: bool=False, *, debug: Optional[bool] = None, ) -> None: @@ -375,6 +377,7 @@ def __init__( """ self.verify_ssl = verify_ssl + self.disable_strict_ssl_verification = disable_strict_ssl_verification """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. diff --git a/samples/openapi3/client/petstore/python/petstore_api/rest.py b/samples/openapi3/client/petstore/python/petstore_api/rest.py index a265bee3515c..24c702af88c4 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python/petstore_api/rest.py @@ -143,6 +143,13 @@ def __init__(self, configuration) -> None: configuration.assert_hostname ) + if configuration.disable_strict_ssl_verification: + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert, + cadata=configuration.ca_cert_data, + ) + ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT + pool_args['ssl_context'] = ssl_context if configuration.retries is not None: pool_args['retries'] = configuration.retries