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
import ConfigParser
import hashlib
import httplib
import inspect
import json
import logging
import os
import ssl
import shutil
import sys
import tarfile
......@@ -149,14 +151,22 @@ class NetworkcacheClient(object):
headers['Authorization'] = 'Basic %s' % ('%s:%s' % (
parsed_url.username, parsed_url.password)).encode('base64').strip()
headers["Connection"] = "close"
connection_kw = {
'host': parsed_url.hostname,
'port': parsed_url.port,
'timeout': timeout,
}
if parsed_url.scheme == 'https':
connection = httplib.HTTPSConnection(parsed_url.hostname, parsed_url.port,
cert_file=self.config.get('sha%s-cert-file' % where),
key_file=self.config.get('sha%s-key-file' % where),
timeout=timeout)
connection_kw['cert_file'] = self.config['sha%s-cert-file' % where]
connection_kw['key_file'] = self.config['sha%s-key-file' % where]
if 'context' in inspect.getargspec(
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:
connection = httplib.HTTPConnection(parsed_url.hostname, parsed_url.port,
timeout=timeout)
connection = httplib.HTTPConnection(**connection_kw)
try:
connection.request(method, parsed_url.path, data, headers)
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