8
votes

I want to list all the issues in a github repository.

Python3 code:

import gitlab
gl = gitlab.Gitlab('https://git.myinternalsite.com/project', private_token='XXXXXXXXXXXXXXX', api_version=4) 

issues = gl.issues.list()

This generates the following error:

SSLError: HTTPSConnectionPool(host='git.zonetrading.com', port=443): Max retries exceeded with url: /cloudquant/user-issues/api/v4/issues (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))

Any ideas on how to correct the error?

2
Are you using a self signed certificate? - secustor
Not using a self-signed certificate. The only thing not shown is that the private token was created on our internal gitlab installation (XXXXX was provided). I did try using UID and PWD and got the same SSLError. - TayloeD

2 Answers

6
votes

The problem seems to be a faulty configured webserver.

The TLS certificate is only certified for the domain www.parkingcrew.comand not for git.zonetrading.com this leads to the certificate verify failederror.

To fix this you have to request a new certificate which includes the target domain, in this case git.zonetrading.com.

To confirm this is the only error, you can turn off the certificate verification in the client using the ssl_verify parameter.

gl = gitlab.Gitlab('https://git.myinternalsite.com/project', private_token='XXXXXXXXXXXXXXX', api_version=4, ssl_verify=False) 
-1
votes

Thanks for the feedback everyone. Here is how I ended up solving this:

Additional info... our enterprise github doesn't have a proper certificate, so warnings were generated.

##########################################
# Dump one ticket to screen so you can see
# all the fields available.
##########################################
import pycurl
from io import BytesIO

buffer = BytesIO()

c = pycurl.Curl()

#
# using a private token from git. Had to register my token
# as a function within the github user profile settings
#
private_token = 'private_token=XXXXXMyPrivateTokenXXXXX'

#
# projects/3 - I had to dump the project list to find the id number 
# of the project that I wanted to get all the issues for
#
GitAPIurl = 'https://git.****MyDomain***.com/api/v4/projects/3/issues?{}'.format(private_token)

c.setopt(c.URL,GitAPIurl)
# turn off SSL verification because we don't have a proper SSL Certification
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()

body = []

body = buffer
# Body is a byte string.
# We have to know the encoding in order to print it to a text file
# such as standard output.

foo = {}
dictionary = json.loads(buffer.getvalue())
foo = dictionary[0]

print(foo)