OCA / connector-magento

Connect Odoo with Magento
http://odoo-magento-connector.com/
GNU Affero General Public License v3.0
105 stars 207 forks source link

Cannot import or synchronize in ssl #209

Open autoslide opened 8 years ago

autoslide commented 8 years ago

Hello all, Since I installed my website HTTPS synchronization stop working as well as import. I have a strange message:

Traceback (most recent call last):
  File "/opt/odoo/odoo/openerp/http.py", line 539, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/openerp/http.py", line 576, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/openerp/http.py", line 312, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/http.py", line 309, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/openerp/http.py", line 805, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/openerp/http.py", line 405, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 948, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/.local/share/Odoo/addons/8.0/magentoerpconnect/magento_model.py", line 198, in synchronize_metadata
    import_batch(session, model, backend.id)
  File "/opt/odoo/.local/share/Odoo/addons/8.0/magentoerpconnect/unit/import_synchronizer.py", line 370, in import_batch
    importer.run(filters=filters)
  File "/opt/odoo/.local/share/Odoo/addons/8.0/magentoerpconnect/unit/import_synchronizer.py", line 239, in run
    record_ids = self.backend_adapter.search(filters)
  File "/opt/odoo/.local/share/Odoo/addons/8.0/magentoerpconnect/unit/backend_adapter.py", line 211, in search
    [filters] if filters else [{}])
  File "/opt/odoo/.local/share/Odoo/addons/8.0/magentoerpconnect/unit/backend_adapter.py", line 182, in _call
    '%s' % err)
NetworkRetryableError: A network error caused the failure of the job: [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

My certificat SSL is Letsencrypt, Odoo server 8 My openssl version: OpenSSL 1.0.2g 1 Mar 2016 My Python version 2.7.6 Apache 2.4.20

My certifiate settings:

# Baseline setting to Include for SSL sites
SSLEngine on

# modern configuration, tweak to your needs
SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite          ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
SSLHonorCipherOrder     on
SSLCompression          off
SSLSessionTickets       off

SSLOptions +StrictRequire

My website magento is on cloudflare proxy and i googled this issue : SNI problem The fix is to add -servername 'mywebsite.com' at the end of location but no working.

echo "" | /usr/bin/openssl s_client -connect autoslide.fr:443 bad echo "" | /usr/bin/openssl s_client -connect autoslide.fr:443 -servername autoslide.fr working

where i can fix that?

Anyone have experience with ssl??

Best regard

StefanRijnhart commented 8 years ago

Hi, I had the same problem just now, also with a Cloudflare connection demanding SNI. I am using requests-2.10.0 which has optional SNI support as long as ndg-httpsclient is installed.

pip install ndg-httpsclient

This required the Linux package libffi-dev on our systems.

StefanRijnhart commented 8 years ago

Sorry, just realized that you will not be using requests, which I am using to connect to Magento 2.0, but rather xmrpclib, which uses urllib. The solution will be different in that case.

sdalexander commented 7 years ago

Hi Guys we are getting a similar error when Importing products through the connector. The sale orders and partners work OK.

2017-03-09 19:04:41,922 23214 ERROR PMC_prod openerp.addons.connector.queue.worker: Traceback (most recent call last): File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/connector/queue/worker.py", line 124, in run_job job.perform(session) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/connector/queue/job.py", line 467, in perform self.result = self.func(session, *self.args, *self.kwargs) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/magentoerpconnect/unit/import_synchronizer.py", line 388, in import_record importer.run(magento_id, force=force) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/magentoerpconnect_extended/models/import_synchronizer.py", line 185, in run self._after_import(binding) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/magentoerpconnect/product.py", line 595, in _after_import image_importer.run(self.magento_id, binding.id) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/magentoerpconnect/product.py", line 373, in run binary = self._get_binary_image(images.pop()) File "/var/lib/odoo/.local/share/Odoo/addons/8.0/magento_connector/magentoerpconnect/product.py", line 354, in _get_binary_image binary = urllib2.urlopen(request) File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 404, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 422, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain result = func(args) File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open raise URLError(err) URLError: <urlopen error [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error>

We are using Odoo v8 and Magento 1.9.2.1 the Magento site is behind a Cloudflare DNS config which is causing the issue as when we switch that off the products load ok..

looking at the code only the product.py uses urllib2.py , partners.py and sales.py don't show that as an import. Would it be possible to get the product.py to use the same methods as the partners & sale modules?

regards Steve

StefanRijnhart commented 7 years ago

True. I rewrote this bit to use requests in my WIP Magento2 branch. You take try out this version of _get_binary_image: https://github.com/OCA/connector-magento/compare/8.0...StefanRijnhart:8.0-magento2#diff-e6aa57638574fdfdf0ef02e82265e3e7L331

StefanRijnhart commented 7 years ago

Oh, you might want to remove the reference to self.backend_record.verify_ssl, which is a new field that I introduced.