Skip to content

SSLContext.wrap_socket() throws a TypeError when attempting to connect to a switch using transport: https_certs #290

@micabrer-arista

Description

@micabrer-arista

Pyeapi is throwing the following error when attempting to connect to a switch via the https_certs transport type:

  File "/Users/micabrer/.pyenv/versions/3.11.4/lib/python3.11/site-packages/pyeapi/eapilib.py", line 261, in connect
    self.sock = ssl.SSLContext.wrap_socket(sock, self.key_file,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SSLContext.wrap_socket() got an unexpected keyword argument 'cert_reqs'

The issue is that ssl.SSLContext.wrap_socket() doesn't accept an argument for cert_reqs. (Reference)

The call that is failing is this one:

255         if self.ca_file:
256             self.sock = ssl.SSLContext.wrap_socket(sock, self.key_file,
257                                                    self.cert_file,
258                                                    ca_certs=self.ca_file,
259                                                    cert_reqs=ssl.CERT_REQUIRED)
260         else:
261             self.sock = ssl.SSLContext.wrap_socket(sock, self.key_file,
262                                                    self.cert_file,
263                                                    cert_reqs=ssl.CERT_NONE)

It looks like this was originally built to be used with ssl.wrap_socket as the arguments match what that function requires. (Reference)

This will likely need to be updated to properly work with the SSLContext.wrap_socket() function, as the ssl.wrap_socket() function is deprecated.

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