IBM / ibm-cos-sdk-python

ibm-cos-sdk-python
Apache License 2.0
45 stars 26 forks source link

Disable cert verification #7

Closed echin20 closed 6 years ago

echin20 commented 6 years ago

I was wondering if there was a way to disable cert verification?

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html

seamus-mcgrath commented 6 years ago

Hi @echin20 I'll look into it and get back to you.

seamus-mcgrath commented 6 years ago

Hi @echin20 you can set verify=false on the api call as below;

def test_cos_sdk_missing_service_instance_id_put_bucket():
    ctx = targets.main
    client = boto3.client('s3', 
                          ibm_api_key_id=ctx.ibm_api_key_id, 
                          ibm_service_instance_id=None, # Missing
                          ibm_auth_endpoint=ctx.ibm_auth_endpoint, 
                          endpoint_url=ctx.endpoint_url, 
                          verify=False,
                          config=Config(signature_version='oauth'))

    bucket_name = get_new_bucket_name()
    e = assert_raises(Exception, client.create_bucket, Bucket=bucket_name)

    response = e.response['Error']
    eq(int(response.get('httpStatusCode')), 400)
    eq(response.get('Code'), 'InvalidArgument')

To disable the warning for an insecure connection you need to; set PYTHONWARNINGS="ignore"

Let me know if this works for you.

echin20 commented 6 years ago

@smcgrath-IBM, I had the verify=False set.

I end up putting this in my code to ignore the warnings rather then setting a environment variable.

import warnings warnings.filterwarnings("ignore")

Thanks for looking into this!