Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from shubb30/disable-ssl-validation
Browse files Browse the repository at this point in the history
SSL validation
  • Loading branch information
etlweather authored Jul 25, 2017
2 parents b54b4b5 + 9041b8f commit 3499fc3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ environment variables:
- `CATTLE_SECRET_KEY`
- `CATTLE_URL`

#### SSL Validation

If you want to turn off SSL validation because you are using a self-signed certificate
or a private CA-signed certificate, you can pass the environment variable:

- `SSL_VERIFY=false`

You can also mount the SSL certificate chain into the container, and pass the path to the
certificate as an environment variable:

- `-v /path/to/ca_chain.crt:/root/ca.crt`
- `-e SSL_VERIFY=/root/ca.crt`

#### Rancher Agent Container

If you run Gaucho in a container on Rancher, rather than set the environment
Expand Down
13 changes: 10 additions & 3 deletions services.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
URL_SERVICE = "/services/"
USERNAME = "userid"
PASSWORD = "password"
kwargs = {}

# HTTP
def get(url):
r = requests.get(url, auth=(USERNAME, PASSWORD))
r = requests.get(url, auth=(USERNAME, PASSWORD), **kwargs)
r.raise_for_status()
return r

def post(url, data):
if data:
r = requests.post(url, data=json.dumps(data), auth=(USERNAME, PASSWORD))
r = requests.post(url, data=json.dumps(data), auth=(USERNAME, PASSWORD), **kwargs)
else:
r = requests.post(url, data="", auth=(USERNAME, PASSWORD))
r = requests.post(url, data="", auth=(USERNAME, PASSWORD), **kwargs)
r.raise_for_status()
return r.json()

Expand Down Expand Up @@ -382,6 +383,12 @@ def state(service_id=""):
if 'RANCHER_URL' in os.environ:
HOST = os.environ['RANCHER_URL']

if 'SSL_VERIFY' in os.environ:
if os.environ['SSL_VERIFY'].lower() == "false":
kwargs['verify'] = False
else:
kwargs['verify'] = os.environ['SSL_VERIFY']

# make sure host ends with v1 if it is not contained in host
if '/v1' not in HOST:
HOST = HOST + '/v1'
Expand Down

0 comments on commit 3499fc3

Please sign in to comment.