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

Commit 500d7ce

Browse files
committed
Add new option cacerts.
This way you can override the CAs, that are used for http communication.
1 parent 83db161 commit 500d7ce

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/fast_puller_.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@
4444
parser.add_argument('--directory', action='store',
4545
help='Where to save the image\'s files.')
4646

47+
parser.add_argument('--cacerts', help='A file, which contains all certs to use')
48+
4749
_THREADS = 8
4850

4951

52+
def _apply_ca_certs(callable, ca_certs):
53+
"""Apply ca_certs attribute to default transport"""
54+
def _call_with_a_certs(*args, **kwargs):
55+
return callable(*args, ca_certs = ca_certs, **kwargs)
56+
return _call_with_a_certs
57+
58+
5059
def main():
5160
logging_setup.DefineCommandLineArgs(parser)
5261
args = parser.parse_args()
@@ -55,6 +64,11 @@ def main():
5564
if not args.name or not args.directory:
5665
raise Exception('--name and --directory are required arguments.')
5766

67+
if args.cacerts:
68+
logging.info('Adding CA certificates of %s', args.cacerts)
69+
retry_transport.DEFAULT_SOURCE_TRANSPORT_CALLABLE = _apply_ca_certs(
70+
retry_transport.DEFAULT_SOURCE_TRANSPORT_CALLABLE, args.cacerts)
71+
5872
retry_transport_factory = retry_transport.Factory()
5973
transport = transport_pool.Http(retry_transport_factory.Build, size=_THREADS)
6074

0 commit comments

Comments
 (0)