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

Certificate verify failed: unable to get local issuer certificate #142

Open javivu opened 1 month ago

javivu commented 1 month ago

Hi to all!

Trying to execute "./nb-dt-import.py" i got the error: urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)

My deploy:

My .env: NETBOX_URL=https://netbox.mydomain.com/ NETBOX_TOKEN=******* REPO_URL=https://github.com/netbox-community/devicetype-library.git REPO_BRANCH=master IGNORE_SSL_ERRORS=False

If I try to use IGNORE_SSL_ERRORS=True another error: pynetbox.core.query.RequestError: The request failed with code 403 Forbidden: {'detail': 'Authentication credentials were not provided.'}

The script and netbox are installed in the same server.

julianfirminger-united commented 1 month ago

I have the same issue. it's like it is ignoroing the NETBOX_TOKEN var in the env file.

javivu commented 1 month ago

@julianfirminger-united , you have me an idea, we check the code. The problem is in: File "/Device-Type-Library-Import/netbox_api.py", line 50, in verify_compatibility version_split = [int(x) for x in self.netbox.version.split('.')] and File "/Device-Type-Library-Import/venv/lib/python3.10/site-packages/pynetbox/core/api.py", line 111, in version ).get_version() The function get_version() from Pynetbox, don't use token?

javivu commented 1 month ago

@julianfirminger-united I do a "dirty" workaround for the momment, In the file netbox_api.py I modify the function verify_compatibility() because my version of netbox is NetBox 4.0.5

def verify_compatibility(self):
        # nb.version should be the version in the form '3.2'
        #version_split = [int(x) for x in self.netbox.version.split('.')]

        # Later than 3.2
        # Might want to check for the module-types entry as well?
        #if version_split[0] > 3 or (version_split[0] == 3 and version_split[1] >= 2):
        self.modules = True
julianfirminger-united commented 1 month ago

@javivu can confirm this works. Thanks for the work!