Commit f495132e authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Add shacache-ca-file and shadir-ca-file options.

parent 85644b7b
...@@ -16,9 +16,11 @@ import argparse ...@@ -16,9 +16,11 @@ import argparse
import ConfigParser import ConfigParser
import hashlib import hashlib
import httplib import httplib
import inspect
import json import json
import logging import logging
import os import os
import ssl
import shutil import shutil
import sys import sys
import tarfile import tarfile
...@@ -149,14 +151,22 @@ class NetworkcacheClient(object): ...@@ -149,14 +151,22 @@ class NetworkcacheClient(object):
headers['Authorization'] = 'Basic %s' % ('%s:%s' % ( headers['Authorization'] = 'Basic %s' % ('%s:%s' % (
parsed_url.username, parsed_url.password)).encode('base64').strip() parsed_url.username, parsed_url.password)).encode('base64').strip()
headers["Connection"] = "close" headers["Connection"] = "close"
connection_kw = {
'host': parsed_url.hostname,
'port': parsed_url.port,
'timeout': timeout,
}
if parsed_url.scheme == 'https': if parsed_url.scheme == 'https':
connection = httplib.HTTPSConnection(parsed_url.hostname, parsed_url.port, connection_kw['cert_file'] = self.config['sha%s-cert-file' % where]
cert_file=self.config.get('sha%s-cert-file' % where), connection_kw['key_file'] = self.config['sha%s-key-file' % where]
key_file=self.config.get('sha%s-key-file' % where), if 'context' in inspect.getargspec(
timeout=timeout) httplib.HTTPSConnection.__init__).args:
connection_kw['context'] = ssl.create_default_context(
cafile=self.config.get('sha%s-ca-file' % where)
)
connection = httplib.HTTPSConnection(**connection_kw)
else: else:
connection = httplib.HTTPConnection(parsed_url.hostname, parsed_url.port, connection = httplib.HTTPConnection(**connection_kw)
timeout=timeout)
try: try:
connection.request(method, parsed_url.path, data, headers) connection.request(method, parsed_url.path, data, headers)
r = connection.getresponse() r = connection.getresponse()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment