eNMS-automation / eNMS

An enterprise-grade vendor-agnostic network automation platform.
https://www.enms.io/
GNU General Public License v3.0
814 stars 162 forks source link

SSL Exception When Attempting to Import Topology From Netbox #381

Closed adparis99 closed 2 years ago

adparis99 commented 2 years ago

Pretty much the title. I provide the server name/port and configure the built-in service Topology Import service to run once, but when I start it I get the below output. eNMS is running on the same server as Netbox, which generated a self-signed certificate during installation.

`2022-06-17 12:27:49.951960 - info - USER admin - SERVICE Netbox - STARTING 2022-06-17 12:27:49.975106 - error - USER admin - SERVICE Netbox - Traceback (most recent call last): File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn conn.connect() File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/connection.py", line 414, in connect self.sock = ssl_wrapsocket( File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/util/ssl.py", line 453, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_intls) File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/util/ssl.py", line 495, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock) File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "/usr/lib/python3.8/ssl.py", line 1040, in _create self.do_handshake() File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen retries = retries.increment( File "/opt/venv/eNMS/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.111.32.69', port=443): Max retries exceeded with url: /api/dcim/devices/?limit=0 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/venv/eNMS/eNMS/eNMS/runner.py", line 496, in run_service_job results = self.service.job(self, *args) File "/opt/venv/eNMS/eNMS/eNMS/models/services/miscellaneous/topologyimport.py", line 36, in job getattr(self, f"query{self.import_type}")() File "/opt/venv/eNMS/eNMS/eNMS/models/services/miscellaneous/topology_import.py", line 41, in query_netbox for device in nb.dcim.devices.all(): File "/opt/venv/eNMS/lib/python3.8/site-packages/pynetbox/core/response.py", line 117, in next next(self.response), self.endpoint.api, self.endpoint File "/opt/venv/eNMS/lib/python3.8/site-packages/pynetbox/core/query.py", line 320, in get req = self._make_call(add_params=add_params) File "/opt/venv/eNMS/lib/python3.8/site-packages/pynetbox/core/query.py", line 270, in _make_call req = getattr(self.http_session, verb)( File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 600, in get return self.request("GET", url, kwargs) File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 723, in send history = [resp for resp in gen] File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 723, in history = [resp for resp in gen] File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 266, in resolve_redirects resp = self.send( File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "/opt/venv/eNMS/lib/python3.8/site-packages/requests/adapters.py", line 563, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='10.111.32.69', port=443): Max retries exceeded with url: /api/dcim/devices/?limit=0 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)'))) 2022-06-17 12:27:49.975834 - info - USER admin - SERVICE Netbox - FINISHED`

adparis99 commented 2 years ago

Was able to edit toplogy_import.py to use pynetbox's ability to ignore the certificate error as found here: https://pynetbox.readthedocs.io/en/latest/advanced.html#ssl-verification