From 5e1e01d5fd5f8a14b95db9143fc7bd538cc2811c Mon Sep 17 00:00:00 2001 From: rderewianko Date: Mon, 5 Feb 2018 14:39:02 -0800 Subject: [PATCH 1/2] Update sync.py Added an if statement for allowing invalid SSL. Forgive me this is me starting to dip my toes into python --- sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sync.py b/sync.py index 01647ad..adc6339 100755 --- a/sync.py +++ b/sync.py @@ -143,9 +143,14 @@ async def get_script_template(session, url, user, passwd, script): async def main(args): semaphore = asyncio.BoundedSemaphore(args.limit) - async with aiohttp.ClientSession() as session: - await upload_scripts(session, args.url, args.username, args.password, semaphore) - await upload_extension_attributes(session, args.url, args.username, args.password, semaphore) + if args.allowinvalidssl: + async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: + await upload_scripts(session, args.url, args.username, args.password, semaphore) + await upload_extension_attributes(session, args.url, args.username, args.password, semaphore) + else: + async with aiohttp.ClientSession() as session: + await upload_scripts(session, args.url, args.username, args.password, semaphore) + await upload_extension_attributes(session, args.url, args.username, args.password, semaphore) if __name__ == '__main__': @@ -157,6 +162,7 @@ async def main(args): parser.add_argument('--password') parser.add_argument('--limit', type=int, default=25) parser.add_argument('--verbose', action='store_true') + parser.add_argument('--allowinvalidssl', action='store_true') args = parser.parse_args() loop = asyncio.get_event_loop() From 9e1259ac1913b1168af3d4c8f1a95da5b697054f Mon Sep 17 00:00:00 2001 From: rderewianko Date: Tue, 6 Feb 2018 11:47:51 -0800 Subject: [PATCH 2/2] Update sync.py This _should do it_ --- sync.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sync.py b/sync.py index adc6339..11ab3eb 100755 --- a/sync.py +++ b/sync.py @@ -143,26 +143,21 @@ async def get_script_template(session, url, user, passwd, script): async def main(args): semaphore = asyncio.BoundedSemaphore(args.limit) - if args.allowinvalidssl: - async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: + async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=args.do_not_verify_ssl)) as session: await upload_scripts(session, args.url, args.username, args.password, semaphore) await upload_extension_attributes(session, args.url, args.username, args.password, semaphore) - else: - async with aiohttp.ClientSession() as session: - await upload_scripts(session, args.url, args.username, args.password, semaphore) - await upload_extension_attributes(session, args.url, args.username, args.password, semaphore) - if __name__ == '__main__': asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - parser = argparse.ArgumentParser(description='Sync repo with JSS') + parser = argparse.ArgumentParser(description='Sync repo with JamfPro') parser.add_argument('--url') parser.add_argument('--username') parser.add_argument('--password') parser.add_argument('--limit', type=int, default=25) parser.add_argument('--verbose', action='store_true') - parser.add_argument('--allowinvalidssl', action='store_true') + parser.add_argument('--do_not_verify_ssl', action='store_false') args = parser.parse_args() loop = asyncio.get_event_loop()