0

I am trying to connect to GCP where I have set up my file ("private_key_file") and trying to read the content within that file.

 def gcsStorageClient(errLogRef):        
    try:
    storage_client = storage.Client(os.environ.get("project_name"))
    bucket = storage_client.get_bucket(os.environ.get("bucket_name"))
    blob = bucket.get_blob(os.environ.get("private_key_file"))
    file = blob.download_as_string()
    return file
except Exception as error:
    print("error:: " + error)

But I am seeing the below exception from my MAC OS which is related to SSL Verification, it seems like MAC firewall client is blocking the connect. Is there any way to say SSLVerify false or create a proxy to connect to GCP

exception: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded
with url: /token (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed (_ssl.c:852)

Is there any way to say SSLVerify false or create a proxy to connect to GCP?

PS: All environment values along with json file are already set into the running environment.

Saurabh
  • 975
  • 2
  • 12
  • 27
  • Either the Python environment or the Google Cloud SDK is installed or set up incorrectly on your system. Your problem is that the code cannot correctly handle SSL. Could be missing certificates, out-of-date libraries, incorrect installation, etc. – John Hanley May 07 '21 at 15:43
  • After debugging we found that it is a certificate issue and we need to install the certificate on our system to connect to GCP. – Saurabh May 10 '21 at 10:35

1 Answers1

0

I ran into this recently. Running Install Certificates.command worked for me, but my python version is 3.6.8. I also changed repo python script manually to use python3 (changed #!/usr/bin/env python -> #!/usr/bin/env python3).

Please refer below link for more information:

Mac OSX python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

Vishal K
  • 1,368
  • 1
  • 7
  • 15