Skip to content

Commit c028585

Browse files
authored
Merge pull request #190 from torresashjiancyber/VC-53768-logos-fix-c
security: CWE-295: TLS verification disabled — VC-53768
2 parents 52e291c + 0ef7f21 commit c028585

7 files changed

Lines changed: 25 additions & 12 deletions

File tree

examples/get_cert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ def main():
4242
# Connection will be chosen automatically based on which arguments are passed.
4343
# If token is passed CyberArk Certificate Manager, SaaS connection will be used.
4444
# If user, password, and URL CyberArk Certificate Manager, Self-Hosted will be used.
45-
conn = Connection(url=url, token=token, user=user, password=password,
46-
http_request_kwargs={'verify': False})
4745
# If your CyberArk Certificate Manager, Self-Hosted server certificate signed with your own CA, or available only via proxy, you can specify
4846
# a trust bundle using requests vars:
47+
conn = Connection(url=url, token=token, user=user, password=password,
48+
http_request_kwargs={"verify": "/path-to/bundle.pem"})
49+
# Lab/testing only — DO NOT use in production:
4950
# conn = Connection(url=url, token=token, user=user, password=password,
50-
# http_request_kwargs={"verify": "/path-to/bundle.pem"})
51+
# http_request_kwargs={'verify': False})
5152

5253
request = CertificateRequest(common_name=f"{randomword(10)}.venafi.example.com")
5354
request.san_dns = ["www.client.venafi.example.com", "ww1.client.venafi.example.com"]

examples/ssh_certificates/get_cert_ssh.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ def main():
3131
user = environ.get('TPP_USER')
3232
password = environ.get('TPP_PASSWORD')
3333

34-
connector = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
3534
# If your CyberArk Certificate Manager, Self-Hosted server certificate is signed with your own CA, or available only via proxy,
3635
# you can specify a trust bundle using requests vars:
37-
# connector = venafi_connection(url=url, api_key=api_key, access_token=access_token,
38-
# http_request_kwargs={"verify": "/path-to/bundle.pem"})
36+
connector = venafi_connection(url=url, user=user, password=password,
37+
http_request_kwargs={"verify": "/path-to/bundle.pem"})
38+
# Lab/testing only — DO NOT use in production:
39+
# connector = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
3940

4041
# Create an Authentication object to request a token with the proper scope to manage SSH certificates
4142
auth = Authentication(user=user, password=password, scope=SCOPE_SSH)

examples/ssh_certificates/get_cert_ssh_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ def main():
3131
user = environ.get('TPP_USER')
3232
password = environ.get('TPP_PASSWORD')
3333

34-
connector = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
3534
# If your CyberArk Certificate Manager, Self-Hosted server certificate signed with your own CA, or available only via proxy,
3635
# you can specify a trust bundle using requests vars:
37-
# connector = venafi_connection(url=url, api_key=api_key, access_token=access_token,
38-
# http_request_kwargs={"verify": "/path-to/bundle.pem"})
36+
connector = venafi_connection(url=url, user=user, password=password,
37+
http_request_kwargs={"verify": "/path-to/bundle.pem"})
38+
# Lab/testing only — DO NOT use in production:
39+
# connector = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
3940

4041
# Create an Authentication object to request a token with the proper scope to manage SSH certificates
4142
auth = Authentication(user=user, password=password, scope=SCOPE_SSH)

examples/tpp/get_cert_tpp_token.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ def main():
4141
# If user and password are passed, you can get a new token from them.
4242
# If access_token and refresh_token are passed, there is no need for the username and password.
4343
# If only access_token is passed, the Connection will fail when token expires, as there is no way to refresh it.
44-
conn = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
4544
# If your CyberArk Certificate Manager, Self-Hosted server certificate signed with your own CA, or available only via proxy, you can specify
4645
# a trust bundle using requests vars:
47-
# conn = token_connection(url=url, user=user, password=password,
48-
# http_request_kwargs={"verify": "/path-to/bundle.pem"})
46+
conn = venafi_connection(url=url, user=user, password=password,
47+
http_request_kwargs={"verify": "/path-to/bundle.pem"})
48+
# Lab/testing only — DO NOT use in production:
49+
# conn = venafi_connection(url=url, user=user, password=password, http_request_kwargs={'verify': False})
4950

5051
request = CertificateRequest(common_name=f"{random_word(10)}.venafi.example.com")
5152
request.san_dns = ["www.client.venafi.example.com", "ww1.client.venafi.example.com"]

vcert/connection_cloud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def __init__(self, token, url=None, http_request_kwargs=None):
155155
http_request_kwargs['timeout'] = 180
156156
self._http_request_kwargs = http_request_kwargs
157157

158+
if self._http_request_kwargs.get('verify') is False:
159+
log.warning("TLS certificate verification is DISABLED; credentials and private keys will be transmitted over unverified connections. This configuration is only appropriate for isolated test environments.")
160+
158161
def __str__(self):
159162
return f"[Cloud] {self._base_url}"
160163

vcert/connection_tpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def __init__(self, user, password, url, http_request_kwargs=None):
4646
http_request_kwargs['timeout'] = 180
4747
self._http_request_kwargs = http_request_kwargs or {}
4848

49+
if self._http_request_kwargs.get('verify') is False:
50+
log.warning("TLS certificate verification is DISABLED; credentials and private keys will be transmitted over unverified connections. This configuration is only appropriate for isolated test environments.")
51+
4952
def __setattr__(self, key, value):
5053
if key == '_base_url':
5154
value = self._normalize_and_verify_base_url(value)

vcert/connection_tpp_token.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def __init__(self, url, user=None, password=None, access_token=None, refresh_tok
5252
http_request_kwargs['timeout'] = 180
5353
self._http_request_kwargs = http_request_kwargs or {}
5454

55+
if self._http_request_kwargs.get('verify') is False:
56+
log.warning("TLS certificate verification is DISABLED; credentials and private keys will be transmitted over unverified connections. This configuration is only appropriate for isolated test environments.")
57+
5558
def __setattr__(self, key, value):
5659
if key == '_base_url':
5760
value = self._normalize_and_verify_base_url(value)

0 commit comments

Comments
 (0)