How do I authenticate AsyncIO client with certs (mTLS) #1040
-
I am using python-socketio async client. Is there an example on how to do this. I tried the below snippet, but it fails with SSL error
results in:
versions:
Server is nginx acting as a reverse-proxy to asyncio server. The request is not reaching the server - failing cert validation at nginx - this makes me believe that my code is not passing the certs correctly? Any pointers/thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
This is really a question for the aiohttp project, since that is where the SSL configuration is applied, not in this project. I honestly do not know what the correct syntax is, I have never used client certs for authentication. The response from your server is 400 though, so it doesn't look like an authentication problem, unless nginx is somehow returning incorrect status codes, which is unlikely. |
Beta Was this translation helpful? Give feedback.
-
you are right on the 400 part - i am trying to get more information from the server to know the reason for the error. Client side log of the response shows 400 Bad Request, I see the same error even when I give a totally invalid cert/key combination. Let me get more logs from the server side |
Beta Was this translation helpful? Give feedback.
-
I did a test, I ran a simple asyncio program to test this:
And this runs fine:
In fact I used a similar URL that the socketio was trying to access: added more instrumentation to engineio/asyncio_client.py to dump the response text when the socketio program tries to connect and this is what I see:
So its a cert issue, I need to figure out why the certs are not getting passed through. |
Beta Was this translation helpful? Give feedback.
-
Digging further, I found this
I had set ssl_verify = False : reason being my server cert is self signed and I didn't want to introduce CA and verification at this point. My goal was just to pass the client cert and accept any server cert. Just to see what happens, I set ssl_verify=True and it started working.. The client is now able to connect to the nginx with the end-to-end path working. So it apears that ssl_verify=False has some bearing on the client certs not being sent to the server - this shouldn't be the case? |
Beta Was this translation helpful? Give feedback.
-
Can we add this to the documentation as an example usage [pls feel free to edit the contents] Using client certificates to establish mTLS session with server and authenticating self signed server certificates:
b.t.w: I can send an edit to the doc as well , and you can review it. let me know? |
Beta Was this translation helpful? Give feedback.
Can we add this to the documentation as an example usage
[pls feel free to edit the contents]
Using client certificates to establish mTLS session with server and authenticating self signed server certificates: