Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,552,839
Community Members
 
Community Events
184
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

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 23, 2022

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

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 24, 2022

Hi

 

I found the param to use in the code of the library you are using.

 

https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/rest_client.py#L45

 

Documentation is here also

https://pypi.org/project/atlassian-python-api/

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.

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 27, 2022

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.

Hi Christian, please see the "Answer Accepted" post from me at the top of this thread for details.

oh, sorry.

Many Thanks!

Suggest an answer

Log in or Sign up to answer