diff options
author | Tobias Brox <tobias@redpill-linpro.com> | 2015-11-06 20:29:09 +0100 |
---|---|---|
committer | Tobias Brox <tobias@redpill-linpro.com> | 2015-11-06 20:29:09 +0100 |
commit | 06fad39f06b34245907edbfc40371fe6b410fe21 (patch) | |
tree | cd1d6e7e7be94e473bcdd6a373a65913e4f7b1c5 | |
parent | da1fcd5f9cc4f64795e28a9eeb2be7125541d24a (diff) | |
download | calendar-cli-06fad39f06b34245907edbfc40371fe6b410fe21.zip |
allow servers with a self-signed SSL cert
-rwxr-xr-x | calendar-cli.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/calendar-cli.py b/calendar-cli.py index 636e3bc..df534ad 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -52,8 +52,15 @@ def niy(*args, **kwargs): raise NotImplementedError def caldav_connect(args): + ## args.ssl_verify_cert is a string and can be a path or 'yes'/'no'. + ## the library expects a path or a boolean. + ## Translate 'yes' and 'no' to True and False, or pass the raw string: + ssl_verify_cert = { + 'yes': True, + 'no': False + }.get(args.ssl_verify_cert, args.ssl_verify_cert) # Create the account - return caldav.DAVClient(url=args.caldav_url, username=args.caldav_user, password=args.caldav_pass) + return caldav.DAVClient(url=args.caldav_url, username=args.caldav_user, password=args.caldav_pass, ssl_verify_cert=ssl_verify_cert, proxy=args.caldav_proxy) def find_calendar(caldav_conn, args): if args.calendar_url: @@ -153,7 +160,7 @@ def interactive_config(args, config, remaining_argv): if not section in config: config[section] = {} - for config_key in ('caldav_url', 'caldav_user', 'caldav_pass', 'language', 'timezone', 'inherits'): + for config_key in ('caldav_url', 'caldav_user', 'caldav_pass', 'caldav_proxy', 'ssl_verify_cert', 'language', 'timezone', 'inherits'): print("Config option %s - old value: %s" % (config_key, config[section].get(config_key, '(None)'))) value = raw_input("Enter new value (or just enter to keep the old): ") if value: @@ -550,6 +557,11 @@ def main(): return else: defaults = config_section(config, args.config_section) + if not 'ssl_verify_cert' in defaults: + defaults['ssl_verify_cert'] = 'yes' + if not 'language' in defaults: + ## TODO: shouldn't this be lower case? + defaults['language'] = 'EN' # Parse rest of arguments # Don't suppress add_help here so it will handle -h @@ -563,10 +575,12 @@ def main(): parser.add_argument("--nocaldav", help="Do not connect to CalDAV server, but read/write icalendar format from stdin/stdout", action="store_true") parser.add_argument("--icalendar", help="Read/write icalendar format from stdin/stdout", action="store_true") parser.add_argument("--timezone", help="Timezone to use") - parser.add_argument('--language', help="language used", default="EN") + parser.add_argument('--language', help="language used") parser.add_argument("--caldav-url", help="Full URL to the caldav server", metavar="URL") parser.add_argument("--caldav-user", help="username to log into the caldav server", metavar="USER") parser.add_argument("--caldav-pass", help="password to log into the caldav server", metavar="PASS") + parser.add_argument("--caldav-proxy", help="HTTP proxy server to use (if any)") + parser.add_argument("--ssl-verify-cert", help="verification of the SSL cert - 'yes' to use the OS-provided CA-bundle, 'no' to trust any cert and the path to a CA-bundle") parser.add_argument("--debug-logging", help="turn on debug logging", action="store_true") parser.add_argument("--calendar-url", help="URL for calendar to be used (may be absolute or relative to caldav URL, or just the name of the calendar)") |