Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --insecure option #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions dumpgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def getXMLHeader(config={}, session=None):
header, config = getXMLHeader(config=config, session=session)
else:
print 'XML export on this wiki is broken, quitting.'
logerror(u'XML export on this wiki is broken, quitting.')
logerror(config=config, text=u'XML export on this wiki is broken, quitting.')
sys.exit()
return header, config

Expand Down Expand Up @@ -1684,6 +1684,9 @@ def getParameters(params=[]):
'--pass',
dest='password',
help='Password if authentication is required.')
parser.add_argument('--insecure',
action='store_true',
help='Ignore SSL certificate errors.')

# URL params
groupWikiOrAPIOrIndex = parser.add_argument_group()
Expand Down Expand Up @@ -1738,6 +1741,14 @@ def getParameters(params=[]):
args = parser.parse_args()
# print args

if args.insecure:
# https://stackoverflow.com/a/66207445
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
ssl.SSLContext.verify_mode = property(lambda self: ssl.CERT_NONE, lambda self, newval: None)
requests.packages.urllib3.disable_warnings(category=requests.packages.urllib3.exceptions.InsecureRequestWarning)
print("WARNING: HTTPS certificate verification is disabled.")

# Don't mix download params and meta info params
if (args.xml or args.images) and \
(args.get_wiki_engine):
Expand Down Expand Up @@ -1925,7 +1936,8 @@ def getParameters(params=[]):
'resume': args.resume,
'filenamelimit': 100, # do not change
'force': args.force,
'session': session
'session': session,
'insecure': args.insecure
}

# calculating path, if not defined by user with --path=
Expand Down Expand Up @@ -2553,6 +2565,9 @@ def main(params=[]):
os.mkdir(config['path'])
saveConfig(config=config, configfilename=configfilename)

if other['insecure']:
logerror(config=config, text=u'WARNING: HTTPS certificate verification is disabled.')

if other['resume']:
resumePreviousDump(config=config, other=other)
else:
Expand Down