netbox-community / Device-Type-Library-Import

This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
https://github.com/netbox-community/devicetype-library
MIT License
256 stars 77 forks source link

SSL Problems #16

Closed stefanvdv closed 3 years ago

stefanvdv commented 3 years ago

Hi,

I'm getting following error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/dcim/manufacturers/?name=Juniper (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1123)')))

Is it possible to add the option not to validate the cert. (working with self signed certs).

Kind regards,

Stefan

ndom91 commented 3 years ago

You should be able to add Verify=False on the end of the request method call, i.e. somethign like requests.get('https://google.com', verify=False) in order to disable SSL Cert checking

EDIT: Ah okay so theres no direct usage of the request method, its being called in pynetbox. After a bit of googling, the following should also do the trick. Somewhere right after line 339 add: nb.http_session.verify = False

johskar commented 3 years ago

I got it working by changing nb = pynetbox.api(nbUrl, token=nbToken) in nb-dt-import.py to contain a ssl_verify variable pointing to the cert: nb = pynetbox.api(nbUrl, token=nbToken, ssl_verify='<path-to-cert>') You can also set ssl_verify=False but that'll generate tons of spam in your output about it being disabled so this was cleaner.

Works fine except the warning that my cert has no SAN entries (but that's my own fault)

timofmax commented 3 years ago

I got it working by changing nb = pynetbox.api(nbUrl, token=nbToken) in nb-dt-import.py to contain a ssl_verify variable pointing to the cert: nb = pynetbox.api(nbUrl, token=nbToken, ssl_verify='<path-to-cert>') You can also set ssl_verify=False but that'll generate tons of spam in your output about it being disabled so this was cleaner.

Works fine except the warning that my cert has no SAN entries (but that's my own fault)

Hey @johskar in which format '' should be written? '/root/projects/netbox-docker/localhost+2.pem' ?

ndom91 commented 3 years ago

@johskar you can also put the following towards the top of your file to silence the warning output and also not have to go through the trouble of generating your own certs, etc.

import requests
requests.packages.urllib3.disable_warnings()