Skip to content

Commit 632c5bf

Browse files
committed
fix: Modifying ssl_insecure connection parameter to be False by default.
1 parent 5c6963f commit 632c5bf

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ Connection Parameters
387387
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
388388
| ssl | bool | If SSL is enabled | TRUE | No |
389389
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
390-
| ssl_insecure | bool | Specifies if IDP hosts server certificate will be verified | TRUE | No |
390+
| ssl_insecure | bool | Specifies whether to disable the verification of the IdP host's server SSL certificate. ssl_insecure=True indicates that verification of the IdP host's server SSL certificate will be disabled. It is NOT recommended to disable the verification of an IdP host's server SSL certificate in a production environment. | False | No |
391391
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
392392
| sslmode | str | The security of the connection to Amazon Redshift. verify-ca and verify-full are supported. | verify_ca | No |
393393
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+

redshift_connector/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def connect(
243243
database_metadata_current_db_only : Optional[bool]
244244
Is `datashare <https://docs.aws.amazon.com/redshift/latest/dg/datashare-overview.html>`_ disabled. Default value is True, implying datasharing will not be used.
245245
ssl_insecure : Optional[bool]
246-
Specifies if IdP host's server certificate will be verified. Default value is True
246+
Specifies whether to disable the verification of the IdP host's server SSL certificate. Default value is False. ssl_insecure=True indicates that verification of the IdP host's server SSL certificate will be disabled. It is NOT recommended to disable the verification of an IdP host's server SSL certificate in a production environment.
247247
web_identity_token: Optional[str]
248248
A web identity token used for authentication with JWT.
249249
role_session_name: Optional[str]
@@ -366,7 +366,7 @@ def connect(
366366
if info.credentials_provider in IDC_OR_NATIVE_IDP_PLUGINS_LIST:
367367
raise InterfaceError("Authentication must use an SSL connection.")
368368

369-
if (info.iam is False) and (info.ssl_insecure is False):
369+
if (info.iam is False) and (info.ssl_insecure is True):
370370
raise InterfaceError("Invalid connection property setting. IAM must be enabled when using ssl_insecure")
371371

372372
if info.client_protocol_version not in ClientProtocolVersion.list():

redshift_connector/plugin/jwt_credentials_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def refresh(self: "JwtCredentialsProvider") -> None:
9393
self.last_refreshed_credentials = credentials
9494

9595
def do_verify_ssl_cert(self: "JwtCredentialsProvider") -> bool:
96-
return self.ssl_insecure
96+
return not self.ssl_insecure
9797

9898
def get_idp_token(self: "JwtCredentialsProvider") -> str:
9999
jwt: str = self.get_jwt_assertion()

redshift_connector/redshift_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def __init__(self: "RedshiftProperty", **kwargs):
106106
self.source_address: typing.Optional[str] = None
107107
# if SSL authentication will be used
108108
self.ssl: bool = True
109-
# This property indicates whether the IDP hosts server certificate should be verified.
110-
self.ssl_insecure: bool = True
109+
# This property indicates whether to disable the verification of the IdP host's server SSL certificate.
110+
self.ssl_insecure: bool = False
111111
# ssl mode: verify-ca or verify-full.
112112
self.sslmode: str = "verify-ca"
113113
# Use this property to enable or disable TCP keepalives.

test/unit/plugin/test_azure_oauth2_credentials_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def make_valid_azure_oauth2_provider() -> typing.Tuple[BrowserAzureOAuth2Credent
2121
cp.add_parameter(rp)
2222
return cp, rp
2323

24+
def test_default_parameters_azure_oauth2_specific() -> None:
25+
acp, _ = make_valid_azure_oauth2_provider()
26+
assert acp.ssl_insecure == False
27+
assert acp.do_verify_ssl_cert() == True
28+
2429

2530
def test_add_parameter_sets_azure_oauth2_specific() -> None:
2631
acp, rp = make_valid_azure_oauth2_provider()

test/unit/plugin/test_jwt_credentials_provider.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
import typing
2+
from unittest.mock import patch
3+
4+
import pytest # type: ignore
5+
6+
from redshift_connector import RedshiftProperty
7+
from redshift_connector.plugin import JwtCredentialsProvider
8+
9+
@patch.multiple(JwtCredentialsProvider, __abstractmethods__=set())
10+
def make_valid_jwt_credentials_provider() -> typing.Tuple[JwtCredentialsProvider, RedshiftProperty]:
11+
rp: RedshiftProperty = RedshiftProperty()
12+
jcp: JwtCredentialsProvider = JwtCredentialsProvider() # type: ignore
13+
jcp.add_parameter(rp)
14+
return jcp, rp
15+
16+
def test_default_parameters_jwt_credentials_provider() -> None:
17+
jcp, _ = make_valid_jwt_credentials_provider()
18+
assert jcp.ssl_insecure == False
19+
assert jcp.do_verify_ssl_cert() == True
20+
121
# import base64
222
# import json
323
# import typing

test/unit/plugin/test_saml_credentials_provider.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def make_valid_saml_credentials_provider() -> typing.Tuple[SamlCredentialsProvid
2020
return scp, rp
2121

2222

23+
def test_default_parameters_saml_credentials_provider() -> None:
24+
acp, _ = make_valid_saml_credentials_provider()
25+
assert acp.ssl_insecure == False
26+
assert acp.do_verify_ssl_cert() == True
27+
28+
2329
def test_get_cache_key_format_as_expected() -> None:
2430
scp, _ = make_valid_saml_credentials_provider()
2531
expected_cache_key: str = "{username}{password}{idp_host}{idp_port}{duration}{preferred_role}".format(

0 commit comments

Comments
 (0)