1

When I import "mysql.connector" firstly, it always failed with SSL error. here is my simple code test:

import mysql.connector
from wordpress_xmlrpc import Client, WordPressPost
Client('https://mywordpress/xmlrpc.php','user','password')

and here is the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/e5/.local/lib/python3.6/site-packages/wordpress_xmlrpc/base.py", line 24, in __init__
    self.supported_methods = self.server.mt.supportedMethods()
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1279, in send_request
    self.send_content(connection, request_body)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1309, in send_content
    connection.endheaders(request_body)
  File "/usr/lib/python3.6/http/client.py", line 1249, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1036, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 974, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 1415, in connect
    server_hostname=server_hostname)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 817, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

But,when I import "mysql.connector" after that,like this:

from wordpress_xmlrpc import Client, WordPressPost
import mysql.connector
Client('https://mywordpress/xmlrpc.php','user','password')

Everything is OK. Which is really strange! Can you help me...Thanks!

qazwsdc
  • 11
  • 2
  • Did you try using 'http' without 'S'? Are you working in localhost? – arieelarg Feb 25 '20 at 04:22
  • I have tried another function "urllib.request" but it still wrong.I'm not working in localhost. – qazwsdc Feb 25 '20 at 06:15
  • It seems that as long as it is after "import mysql.connector", it will report an SSL error – qazwsdc Feb 25 '20 at 06:18
  • I believe this is solved here: https://stackoverflow.com/questions/41691327/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c – arieelarg Feb 25 '20 at 18:46
  • No.I'm not a Mac user.The point of the problem is the order of the imported packages, if “mysql.connector” is imported before other packages, an SSL error will be reported.The problem must be with “mysql.connector”. – qazwsdc Feb 26 '20 at 06:55

0 Answers0