-
Notifications
You must be signed in to change notification settings - Fork 3
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
After upgrading requests-credssp to 2.0.0 ansible cannot connect to Windows 2012R2 #27
Comments
Thanks for the bug report, the problem is interesting and I wonder if the problem is due to a failure to negotiate a common cipher suite with older Windows OSs. The older From my limited understanding of how it all work you should be able to use the following to determine what cipher suites each method can offer import ssl
import OpenSSL.SSL
import spnego.tls
ctx = spnego.tls.default_tls_context(usage="initiate").context
print("Builtin ssl info")
print(ssl.OPENSSL_VERSION)
print([c["name"] for c in ctx.get_ciphers()])
print("pyOpenSSL info")
pyopenssl_ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_2_METHOD)
print(OpenSSL.SSL.Connection(pyopenssl_ctx, None).get_cipher_list()) You can also run For example on my Fedora host this is what I have
You can see that pyOpenSSL offers more ciphers than what the builtin module which is most likely due to my OS settings limited what I can use. You can see what cipher suites are available for Server 2012 R2 on this page https://docs.microsoft.com/en-us/windows/win32/secauthn/tls-cipher-suites-in-windows-8-1 but you will have to use https://testssl.sh/openssl-iana.mapping.html to map the OpenSSL format to the RFC format used on the Windows docs. Try and see if there is a common cipher suite that's available in the builtin Finally to test it out you can use a specific cipher suite the following command to verify whether a cipher suite is supported on the Windows host by doing echo "n" | openssl s_client -connect hostname:3389 -tls1_2 -cipher ECDHE-ECDSA-AES256-GCM-SHA384 |
Thanks for the answer. I ran the script and it turned out that in both methods have ciphers supported by Windows 2012R2:
and the command exited with 1. I tried ciphers from the second list and it turned out that for
I am a bit surprised because in both cases I get |
The error 1 with
This is to be expected for the RDP certificate. It is typically an ephemeral cert generated by Windows that is self signed. Unless you've manually set an explicit certificate or use AD CS to configure a cert for RDP then it will use this self signed certificate. The reason why I asked you to test with RDP (port 3389) is that CredSSP will use a similar ephemeral certificate and be subject to the same limitations as RDP. You can control what certificate CredSSP over RDP uses by setting the thumbprint with Set-Item -Path WSMan:\localhost\Service\CertificateThumbprint -Value $thumbprint
From what I can see is that the only common cipher with the builtin ssl module and the server are This leads into the next point which is system wide configuration of OpenSSL. In my
This file contains the following:
The key part here is that
When I manually set this to This might also be why the builtin
The first thing I would suggest is to share your OS information and how you've installed Python 3, Ansible, requests-credssp, pyOpenSSL. Some of these details are highly dependent on how it was installed, pip vs dnf/apt. This can help me try and replicate the problem and offer more suggestions. Failing that this is what I would suggest
Unfortunately this is a complex problem that is only going to get harder in the future as Server 2012 ages and more ciphers get disabled through OpenSSL by default. It doesn't help but it's a sign of why upgrading the OS is important today as things like TLS gets hardened over time and older OS' don't necessarily get the newer protocols and cipher suites backported. |
I had the same issue today. I haven't ran Ansible on my server 2012R2 boxes for a while, and just upgraded to Ubuntu 22.04 - so it's possibly related to the OpenSSL and/or Python updates. Using requests-credssp 2.0 resulted in the server 2012 r2 errors shown above only, and worked fine on everything else (server 2016, 2019 and 2022). I fixed the server 2012 R2 errors by using my WinRM cert for CredSSP also. I also needed to grant Interestingly, using requests-credssp < 2.0 resulted in this error, which I didn't investigate given that 2.0 is current.
|
That is a separate issue jborean93/pyspnego#37. Python on Ubuntu 22.04 doesn't come with md4 enabled which is required for NTLM authentication. You really should be getting Kerberos authentication working and avoiding NTLM but until that linked issue is fixed NTLM won't work. |
@jborean93 I’m having similar issues between python 3.9 and 3.11. Same underlying modules in every step but no success on 3.10/3.11. Is 3.10/3.11 not supported? Is there any way to add cypher suites to ansible/winrm/python |
Unfortunately no, this library is at the mercy of whatever OpenSSL library Python is linked to and the policies that library needs to follow. |
Error from
ansible-playbook
:Here are the versions of packages:
Windows 10 works fine.
Switching to
requests-credssp==1.3.1
fixes the problem.I have full access to the machines so if you need more info or logs, I'll be happy to provide them for you.
The text was updated successfully, but these errors were encountered: