Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Sanity checks on the client cert options
if bool(args_command_list.cert) ^ bool(args_command_list.key):
raise CommandLineParsingError('No private key or certificate file were given. See --cert and --key.')
# Private key and cert formats
if args_command_list.certform == 'DER':
args_command_list.certform = SSL_FILETYPE_ASN1
elif args_command_list.certform == 'PEM':
args_command_list.certform = SSL_FILETYPE_PEM
else:
raise CommandLineParsingError('--certform should be DER or PEM.')
if args_command_list.keyform == 'DER':
args_command_list.keyform = SSL_FILETYPE_ASN1
elif args_command_list.keyform == 'PEM':
args_command_list.keyform = SSL_FILETYPE_PEM
else:
raise CommandLineParsingError('--keyform should be DER or PEM.')
# Let's try to open the cert and key files
if args_command_list.cert:
try:
open(args_command_list.cert,"r")
except:
raise CommandLineParsingError('Could not open the client certificate file "' + str(args_command_list.cert) + '".')
if args_command_list.key:
try:
open(args_command_list.key,"r")
except:
raise CommandLineParsingError('Could not open the client private key file "' + str(args_command_list.key) + '"')
"""
Performs various sanity checks on the command line that was used to
launch SSLyze.
Returns the shared_settings object to be fed to plugins.
"""
shared_settings = {}
# Sanity checks on the client cert options
if bool(args_command_list.cert) ^ bool(args_command_list.key):
raise CommandLineParsingError('No private key or certificate file were given. See --cert and --key.')
# Private key and cert formats
if args_command_list.certform == 'DER':
args_command_list.certform = SSL_FILETYPE_ASN1
elif args_command_list.certform == 'PEM':
args_command_list.certform = SSL_FILETYPE_PEM
else:
raise CommandLineParsingError('--certform should be DER or PEM.')
if args_command_list.keyform == 'DER':
args_command_list.keyform = SSL_FILETYPE_ASN1
elif args_command_list.keyform == 'PEM':
args_command_list.keyform = SSL_FILETYPE_PEM
else:
raise CommandLineParsingError('--keyform should be DER or PEM.')
# Let's try to open the cert and key files
if args_command_list.cert:
try:
open(args_command_list.cert,"r")
except:
raise CommandLineParsingError('Could not open the client certificate file "' + str(args_command_list.cert) + '".')