使API调用TLS ver不匹配时发生SSL错误

2024-05-23 14:48:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图调用一个API,结果得到了SSL错误,很可能是因为TLS版本不匹配。请指导我需要做些什么才能使它发挥作用。你知道吗

` import ssl

  from twilio.rest import Client

  accountSID = 'xxxxxx'
  authToken = 'xxxxxxx
  twilioCli = Client(accountSID, authToken)
  myTwilioNumber = '+14955551234'
  myCellPhone = 'xxxxxxxx'
  message = twilioCli.messages.create(body='Mr.Ankit - you are doing great.', from_=myTwilioNumber, to=myCellPhone)

   print(message.sid)`

Python代码生成错误:

"HTTPSConnectionPool(host='api.twilio.com', port=443): Max retries exceeded with url: /2010-04-01/Accounts/AC1f7769b1600b53ae66ebd6a7c4cd1b92/Messages.json (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))"

SSL版本1.1

Python版本是3.7


Tags: fromimport版本clientsslmessage错误certificate