diff --git a/tools/fast_puller_.py b/tools/fast_puller_.py index c01d6aaf0..8527eca8b 100755 --- a/tools/fast_puller_.py +++ b/tools/fast_puller_.py @@ -45,6 +45,13 @@ parser.add_argument('--directory', action='store', help='Where to save the image\'s files.') +parser.add_argument('--certificates', nargs='*', help='A comma separated ' + + 'tuple of key file, cert, and domain. (From httplib2 ' + + 'docs) Add a key and cert that will be used for an SSL ' + + 'connection to the specified domain. keyfile is the name ' + + 'of a PEM formatted file that contains your private key. ' + + 'certfile is a PEM formatted certificate chain file.') + _THREADS = 8 @@ -58,6 +65,12 @@ def main(): transport = transport_pool.Http(httplib2.Http, size=_THREADS) + if args.certificates: + for item in args.certificates: + logging.info('Adding certificate %s', item) + key, cert, domain = item.split(',') + transport.add_certificate(key, cert, domain) + if '@' in args.name: name = docker_name.Digest(args.name) else: diff --git a/tools/fast_pusher_.py b/tools/fast_pusher_.py index 5a3f8468b..0f89797dc 100755 --- a/tools/fast_pusher_.py +++ b/tools/fast_pusher_.py @@ -61,6 +61,13 @@ parser.add_argument('--oci', action='store_true', help='Push the image with an OCI Manifest.') +parser.add_argument('--certificates', nargs='*', help='A comma separated ' + + 'tuple of key file, cert, and domain. (From httplib2 ' + + 'docs) Add a key and cert that will be used for an SSL ' + + 'connection to the specified domain. keyfile is the name ' + + 'of a PEM formatted file that contains your private key. ' + + 'certfile is a PEM formatted certificate chain file.') + _THREADS = 8 @@ -123,6 +130,12 @@ def main(): transport = transport_pool.Http(httplib2.Http, size=_THREADS) + if args.certificates: + for item in args.certificates: + logging.info('Adding certificate %s', item) + key, cert, domain = item.split(',') + transport.add_certificate(key, cert, domain) + # Resolve the appropriate credential to use based on the standard Docker # client logic. creds = docker_creds.DefaultKeychain.Resolve(name) diff --git a/transport/transport_pool_.py b/transport/transport_pool_.py index fda5550a7..8c9f0e7b4 100755 --- a/transport/transport_pool_.py +++ b/transport/transport_pool_.py @@ -47,6 +47,18 @@ def _return_transport(self, transport): # We returned an item, notify a waiting thread. self._condition.notify(n=1) + def add_certificate(self, key, cert, domain): + """Adds a certificate to all of the underlying transports. + + From httplib2 docs: + + Add a key and cert that will be used for an SSL connection to the + specified domain. keyfile is the name of a PEM formatted file that contains + your private key. certfile is a PEM formatted certificate chain file. + """ + for transport in self._transports: + transport.add_certificate(key, cert, domain) + def request(self, *args, **kwargs): """This awaits a transport and delegates the request call.