python-gitlab api SSL错误握手:错误([('SSL例程','ssl3_get_server_certificate','证书验证失败')],

时间:2018-01-09 22:21:40

标签: python-3.x ssl gitlab

我想在github存储库中列出所有问题。

Python3代码:

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

issues = gl.issues.list()

这会产生以下错误:

  

SSLError:HTTPSConnectionPool(host ='git.zonetrading.com',port = 443):使用url超出最大重试次数:/ cloudquant / user-issues / api / v4 / issues(由SSLError引起(SSLError(“握手不良) :错误([('SSL例程','ssl3_get_server_certificate','证书验证失败')],)“,),))

有关如何纠正错误的任何想法?

2 个答案:

答案 0 :(得分:0)

问题似乎是配置错误的网络服务器。

TLS证书仅针对域www.parkingcrew.com进行了认证,而不是针对git.zonetrading.com进行了认证,这导致certificate verify failed错误。

要解决此问题,您必须申请一个包含目标域的新证书,在本例中为git.zonetrading.com

要确认这是唯一的错误,您可以使用ssl_verify参数关闭客户端中的证书验证。

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

答案 1 :(得分:0)

感谢大家的反馈。 以下是我最终解决这个问题的方法:

其他信息...我们的企业github没有合适的证书,因此产生了警告。

##########################################
# 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)