Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIONetbox doesn't initiate self when Certificate is untrusted #12

Open
microsoftdealer opened this issue Nov 17, 2021 · 1 comment
Open

Comments

@microsoftdealer
Copy link

microsoftdealer commented Nov 17, 2021

Python raises exception from urllib3->requests when creating Netbox object with AIONetbox() or AIONetbox.from_api classmethod.

ssl_ctx = ssl.create_default_context(cafile='./ROOT-SUB-BUNDLE.pem')
session = ClientSession(connector=TCPConnector(ssl=ssl_ctx))

netbox = AIONetbox.from_openapi(
        url='https://netbox.site.com,
        api_key=token,
        session=session,
    )

The reason is that self.parse_spec() uses urllib3 and it forces certifi to check certificate anyway. So, passing session with TCPConnector(ssl=False) doesn't helps.

Rewrite parse_spec to ignore ssl or add certificate to certifi.

EXAMPLE:

with open('TINK-ROOT.pem') as file:
    customca = file.read()
    customca = customca.encode()

cafile = certifi.where()
with open(cafile, 'ab') as outfile:
    outfile.write(b'\n')
    outfile.write(customca)
@marcoceppi
Copy link
Contributor

Thanks for the issue! We're nearing holidays in the US, but will try to get a fix together if you don't get to it first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants