Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Add new option cacerts.
Browse files Browse the repository at this point in the history
This way you can override the CAs, that are used for http communication.
  • Loading branch information
abergmeier committed Dec 27, 2017
1 parent 83db161 commit 500d7ce
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/fast_puller_.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@
parser.add_argument('--directory', action='store',
help='Where to save the image\'s files.')

parser.add_argument('--cacerts', help='A file, which contains all certs to use')

_THREADS = 8


def _apply_ca_certs(callable, ca_certs):
"""Apply ca_certs attribute to default transport"""
def _call_with_a_certs(*args, **kwargs):
return callable(*args, ca_certs = ca_certs, **kwargs)
return _call_with_a_certs


def main():
logging_setup.DefineCommandLineArgs(parser)
args = parser.parse_args()
Expand All @@ -55,6 +64,11 @@ def main():
if not args.name or not args.directory:
raise Exception('--name and --directory are required arguments.')

if args.cacerts:
logging.info('Adding CA certificates of %s', args.cacerts)
retry_transport.DEFAULT_SOURCE_TRANSPORT_CALLABLE = _apply_ca_certs(
retry_transport.DEFAULT_SOURCE_TRANSPORT_CALLABLE, args.cacerts)

retry_transport_factory = retry_transport.Factory()
transport = transport_pool.Http(retry_transport_factory.Build, size=_THREADS)

Expand Down

0 comments on commit 500d7ce

Please sign in to comment.