Skip to content

Not able to authenticate using certificate and key files #314

@roopeshsn

Description

@roopeshsn

I've used transport as http_certs. My .conf file looks like below where I've provided path to signed certificate and private key files,

[connection:dut]
host: 10.10.10.1
transport: https_certs
cert_file: "/Users/roopesh/Desktop/projects/pyapi-test/cert.pem"
key_file: "/Users/roopesh/Desktop/projects/pyapi-test/key.pem"

Also here's my simple python script,

import pyeapi

pyeapi.load_config('nodes.conf')
node = pyeapi.connect_to('dut')

config = node.get_config('running-config')
print(config)

When I ran the above script, I got the following error,

roopesh:pyapi-test/ $ /Users/roopesh/Desktop/projects/pyapi-test/.venv/bin/python /Users/roopesh/Desktop/projects/pyapi-test/main.py                                             [10:03:14]
Traceback (most recent call last):
  File "/Users/roopesh/Desktop/projects/pyapi-test/main.py", line 4, in <module>
    node = pyeapi.connect_to('dut')
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/roopesh/Desktop/projects/pyapi-test/.venv/lib/python3.12/site-packages/pyeapi/client.py", line 1046, in connect_to
    node = connect(return_node=True, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/roopesh/Desktop/projects/pyapi-test/.venv/lib/python3.12/site-packages/pyeapi/client.py", line 453, in connect
    connection = make_connection(transport, host=host, username=username,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/roopesh/Desktop/projects/pyapi-test/.venv/lib/python3.12/site-packages/pyeapi/client.py", line 391, in make_connection
    return klass(**kwargs)
           ^^^^^^^^^^^^^^^
  File "/Users/roopesh/Desktop/projects/pyapi-test/.venv/lib/python3.12/site-packages/pyeapi/eapilib.py", line 708, in __init__
    self.transport = HTTPSCertConnection(path, host, int(port),
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/roopesh/Desktop/projects/pyapi-test/.venv/lib/python3.12/site-packages/pyeapi/eapilib.py", line 222, in __init__
    HTTPSConnection.__init__(self, host, key_file=key_file,
TypeError: HTTPSConnection.__init__() got an unexpected keyword argument 'key_file'

It seems key_file argument is not properly handled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions