Trouble with dbt cloud SSL cert [SSL: CERTIFICATE_VERIFY_FAILED]

On Prefect Cloud 2.0
Error:
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)

Hey all,

I am trying to set up Prefect for my company, and I am trying to set up the dbt cloud credentials for the credentials block. The tutorial was fairly straight forward, but I can’t seem to authenticate properly.

My code is as follows:

from prefect_dbt.cloud import DbtCloudCredentials

DbtCloudCredentials(
    api_key="api_key",
    account_id="account_id"
).save("dbt-admin-block")

Where the api key was copied directly from dbt cloud and the account id was taken from the url at https://cloud.getdbt.com/settings/accounts/HERE/pages/projects

I have also tried using a few other admins’ api keys and none of them worked.

Does anyone have any idea of how I can fix this?

Edit: I have also tried to implement a Snowflake credential block and run into the same issue. I am 100% sure my credentials for that one are correct.

I fixed it myself

Solution:
Put this above your credential block code

import httpx
import ssl
import truststore

ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client = httpx.Client(verify=ssl_context)