-
Notifications
You must be signed in to change notification settings - Fork 70
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
Certificate validation doesn't work #174
Comments
Hi @zloo, I've added support for using valid certs into pyeapi via a new transport type 'https_certs'. The new transport class is 'HttpsEapiCertConnection' and is available in the develop branch. I've documented how to use the new transport and it's associated parameters here. Below is an example config file and python usage: key_file - full path to user private key **ca_file is optional and if provided will validate the server against the CA as well. https_certs is the new transport type used for validating certs. Example eapi.conf:
Example Python usage:
Let me know if this satisfies your needs. |
Hi @mharista, thank you for the reply. The develop branch is solving a completely unrelated issue - client verification via CA. The issue I'm having is that there is no way to force validation (or verification) of the certificate on Arista box, because you disable it by default and provide no option to enable it. This means that anyone on the path between the pyeapi client and Arista box can do a MitM attack and steal user credentials. |
I think I am misunderstanding something. The new transport class does do the certificate validation and requires valid certs on the switch and optionally a CA cert as well. This connection transport does not require a username or password. |
I am using username and password for logging into the switch. The https transport has a bug that it doesn't allow verification of the switch SSL certificate. There is a reference to a parameter called If I understand your new connection type correctly, it allows me to verify the Switch certificate, BUT i need to use client certificates+key for authentication. |
That is correct for the new connection type. What type of certificate do you have on your switch, a self-signed cert or a CA signed cert? What are you planning to use to validate the switches cert? |
I have a normal certificate issued by a public certificate authority. I want to validate it against the system CA list, but I don't mind if I have to specifically tell the system to use a specific file as the CA. |
So you want to use username/password and potentially pass a ca_file to validate the servers certificate against? I'm not sure what the system CA list is. Have you tried this with the |
Yes, that's what I want. The system CA list depends on the underlying python library that pyeapi uses. python-requests uses its own CA set, others might fall back to the system I did not try to hack it, but I can try tomorrow. |
Gotcha. In that case I have more confidence that simply fixing the |
Hi @zloo Were your tests with the hacked parameter and current cert setup successful? |
hi @mharista |
Hi @zloo Did you ever have a chance to test the param in your cert environment? |
Trying to also setup this authentication type, I seem to be getting this error: But also can't find any documentation on how to include username into configured/trusted client certificate so far. So if you get around to making the test-case for the API, would greatly appreciate if you might also include e.g. openssl command creating the client cert itself there. EDIT: found client-side cert generation info on the api https port, didn't think to check there, but still would be nice if whole https_certs mode was documented and had an example in this client as well. |
Fixes arista-eosplus#174 It feels a bit odd to be passing such a chunky object all around, but it's convenient. Tests updated to not explicitly expect default parameters to be passed.
Hi @zloo, @mk-fg, with the recent fix #236, you can pass ssl context to pyeapi client connector. You create ssl context outside of pyeapi, where you can provide client side certificate as well as CA certificate and force checking of the server's TLS certificate. The fix effectively obsoletes and deprecates The fix is available in the With this I'm closing this issue, let me know if any questions. |
I tried to make certificate validation work, but it seems it's not possible at the moment.
The validation is disabled by default, and if you want to enable it, you have to pass
enforce_verification
in kwargs to HttpsEapiConnection constructor.This constructor is only ever called from client.py / make_connection(), which in turn is only ever called from this line:
pyeapi/pyeapi/client.py
Line 427 in 35557de
As you can see, we never pass the
enforce_verification
tomake_connection
function.We need to either pass down **kwargs, or at the very least the
enforce_verification
should it ever be set.The text was updated successfully, but these errors were encountered: