Skip to content
Snippets Groups Projects
Verified Commit 43bd43c9 authored by Thorsten Roßner's avatar Thorsten Roßner
Browse files

feat: Support --verify_certificate option for private CA dev scenario

parent 9691fd21
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ from requests.auth import HTTPBasicAuth
class Ucs:
def __init__(self, adm_username, adm_password, base_url, maildomain, options_object, ldap_base='dc=swp-ldap,dc=internal'):
def __init__(self, adm_username, adm_password, base_url, maildomain, options_object, ldap_base='dc=swp-ldap,dc=internal', verify_certificate=True):
self.user = None
self.user_updated = False
self.adm_username = adm_username
......@@ -23,6 +23,7 @@ class Ucs:
self.user_base = 'cn=users,'+ldap_base
self.group_base = 'cn=groups,'+ldap_base
self.maildomain_base = 'cn=domain,cn=mail,'+ldap_base
self.verify_certificate = verify_certificate
self.options_object = options_object
self.timestamp = datetime.now().strftime('%Y-%m-%dT%Hh%Mm%SZ')
self.create_count = { 'users': 0, 'maildomains': 0, 'groups': 0, 'oxcontexts': 0 }
......@@ -117,7 +118,8 @@ class Ucs:
data=data,
params=query_param,
headers=http_headers,
auth=HTTPBasicAuth(self.adm_username, self.adm_password)
auth=HTTPBasicAuth(self.adm_username, self.adm_password),
verify=self.verify_certificate
)
if response.status_code not in allowed_responses:
logging.error(f"1/2: Stopping due to response's http status {str(response.status_code)}")
......
......@@ -215,6 +215,14 @@ p.add(
default="Administrator",
help="User to authentication against the UDM REST API with.",
)
p.add(
"--verify_certificate",
env_var="VERIFY_CERTIFICATE",
default=True,
type=opt2bool,
help='Optional: DEV MODE ONLY - NEVER USE THIS IN PRODUCTION SCENARIO: Set to "False" to skip certificate check on the API calls.',
)
options = p.parse_args()
new_user_password = options.set_default_password
......@@ -268,6 +276,7 @@ ucs = Ucs(
base_url=options.import_domain,
maildomain=import_maildomain,
options_object=options,
verify_certificate=options.verify_certificate
)
if not options.import_filename:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.