Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,932
Community Members
 
Community Events
165
Community Groups

The dreaded CERTIFICATE_VERIFY_FAILED with Python Bitbucket API

Hi all,

I'm trying to connect to our internal Bitbucket server via the Atlassian Python API, using a token:

from atlassian import Bitbucket

bb = Bitbucket(url='https://<ourURL>',token = '<myToken>')
data = bb.project_list()
for i in data:
    print(i)

 

When I run the above code I get the error "SSL: CERTIFICATE_VERIFY_FAILED".

I'm running on a Mac, using IDLE.  

I've tried adding a "verify=False" to the connection string, but then I get an error that the parameter "verify" isn't recognized.

I'm new to using APIs (and certificates) so I'm probably missing something basic here.  Any ideas?

Thanks!

 

2 answers

1 accepted

0 votes
Answer accepted

I was able to get this to work following these steps:

Specify the certificate store per:

https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore

This included:
1) Installed “certifi”
2) Added this to my .bash_profile:
CERT_PATH=$(python3.8 -m certifi)
export SSL_CERT_FILE=${CERT_PATH}
export REQUESTS_CA_BUNDLE=${CERT_PATH}

3) Linked “ln -s” the cacert.pem file to the cert.pem file

 

Then I re-added the internal Certs for our repos to the cacert.pem file

Hi

 

Have you try  verify_ssl=False ?

 

Bitbucket(url='https://<ourURL>',token = '<myToken>', verify_ssl=False)

Hi Florian, 

This is much closer!  Now I get a string of 30 warnings:

"InsecureRequestWarning: Unverified HTTPS request is being made to host...Adding certificate verification is strongly advised."

These are followed by:

"requests.exceptions.TooManyRedirects: Exceeded 30 redirects.".

Is there a way to disable warnings?  

And how did you find the verify_ssl parameter?  Is there documentation somewhere that I missed?

Thanks so much for the help!

--Rob

Aha, thanks for that!  Unfortunately I don't see a way to disable the warnings to get this to work with the verify_ssl=False flag. 

I've tried multiple solutions to the SSL certificate problem (such as running "Install Certificates.command"),  but so far nothing has worked.

Usually it's ok to have warning, the "requests.exceptions.TooManyRedirects: Exceeded 30 redirects." is another error.

 

Can you try to add an header to your request following this recommandation

https://stackoverflow.com/questions/23651947/python-requests-requests-exceptions-toomanyredirects-exceeded-30-redirects

Thank you for the help!  I eventually got it to work, details in the next post.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you