ansible-collections / ansible.windows

Windows core collection for Ansible
https://galaxy.ansible.com/ansible/windows
GNU General Public License v3.0
249 stars 169 forks source link

Connection aborted.', OSError(\"(104, 'ECONNRESET')\") on connect to Windows Server 2022 #333

Closed sandroLuk closed 2 years ago

sandroLuk commented 2 years ago
SUMMARY

I try to get ansible running to orchestrate a Windows Server 2022 host. The Server is fresh build from Windows Installer and only got the ansible connection-setup powershell script running on it. We use the same script for Windows Server 2019 and 2016 and it runs fine there. The connect is done by certificate.

When i try to connect with Ansible to the server i got that error:

fatal: [10.176.4.115]: UNREACHABLE! => {
    "changed": false,
    "msg": "certificate: ('Connection aborted.', OSError(\"(104, 'ECONNRESET')\"))",
    "unreachable": true
}
ISSUE TYPE
COMPONENT NAME

Ansible basic functionality - Gather Facts (i guess its core?)

ANSIBLE VERSION
ansible [core 2.12.1]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    2.1.0  
ansible.netcommon             2.5.0  
ansible.posix                 1.3.0  
ansible.utils                 2.4.3  
ansible.windows               1.9.0  
arista.eos                    3.1.0  
awx.awx                       19.4.0 
azure.azcollection            1.10.0 
check_point.mgmt              2.2.0  
chocolatey.chocolatey         1.1.0  
cisco.aci                     2.1.0  
cisco.asa                     2.1.0  
cisco.intersight              1.0.18 
cisco.ios                     2.6.0  
cisco.iosxr                   2.6.0  
cisco.ise                     1.2.1  
cisco.meraki                  2.6.0  
cisco.mso                     1.3.0  
cisco.nso                     1.0.3  
cisco.nxos                    2.8.2  
cisco.ucs                     1.6.0  
cloud.common                  2.1.0  
cloudscale_ch.cloud           2.2.0  
community.aws                 2.1.0  
community.azure               1.1.0  
community.ciscosmb            1.0.4  
community.crypto              2.1.0  
community.digitalocean        1.14.0 
community.dns                 2.0.4  
community.docker              2.1.1  
community.fortios             1.0.0  
community.general             4.3.0  
community.google              1.0.0  
community.grafana             1.3.0  
community.hashi_vault         2.2.0  
community.hrobot              1.2.2  
community.kubernetes          2.0.1  
community.kubevirt            1.0.0  
community.libvirt             1.0.2  
community.mongodb             1.3.2  
community.mysql               2.3.2  
community.network             3.0.0  
community.okd                 2.1.0  
community.postgresql          1.6.0  
community.proxysql            1.3.1  
community.rabbitmq            1.1.0  
community.routeros            2.0.0  
community.skydive             1.0.0  
community.sops                1.2.0  
community.vmware              1.17.0 
community.windows             1.9.0  
community.zabbix              1.5.1  
containers.podman             1.9.0  
cyberark.conjur               1.1.0  
cyberark.pas                  1.0.13 
dellemc.enterprise_sonic      1.1.0  
dellemc.openmanage            4.4.0  
dellemc.os10                  1.1.1  
dellemc.os6                   1.0.7  
dellemc.os9                   1.0.4  
f5networks.f5_modules         1.13.0 
fortinet.fortimanager         2.1.4  
fortinet.fortios              2.1.3  
frr.frr                       1.0.3  
gluster.gluster               1.0.2  
google.cloud                  1.0.2  
hetzner.hcloud                1.6.0  
hpe.nimble                    1.1.4  
ibm.qradar                    1.0.3  
infinidat.infinibox           1.3.3  
infoblox.nios_modules         1.2.1  
inspur.sm                     1.3.0  
junipernetworks.junos         2.8.0  
kubernetes.core               2.2.2  
mellanox.onyx                 1.0.0  
netapp.aws                    21.7.0 
netapp.azure                  21.10.0
netapp.cloudmanager           21.12.1
netapp.elementsw              21.7.0 
netapp.ontap                  21.14.1
netapp.storagegrid            21.9.0 
netapp.um_info                21.8.0 
netapp_eseries.santricity     1.2.13 
netbox.netbox                 3.5.0  
ngine_io.cloudstack           2.2.2  
ngine_io.exoscale             1.0.0  
ngine_io.vultr                1.1.0  
openstack.cloud               1.5.3  
openvswitch.openvswitch       2.1.0  
ovirt.ovirt                   1.6.6  
purestorage.flasharray        1.12.0 
purestorage.flashblade        1.9.0  
sensu.sensu_go                1.12.1 
servicenow.servicenow         1.0.6  
splunk.es                     1.0.2  
t_systems_mms.icinga_director 1.27.0 
theforeman.foreman            2.2.0  
vyos.vyos                     2.6.0  
wti.remote                    1.0.3  
CONFIGURATION
ANSIBLE_PIPELINING(env: ANSIBLE_PIPELINING) = True
DEFAULT_FORKS(env: ANSIBLE_FORKS) = 40
DEFAULT_GATHER_TIMEOUT(env: ANSIBLE_GATHER_TIMEOUT) = 120
DEFAULT_TIMEOUT(env: ANSIBLE_TIMEOUT) = 60
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /prod/.vault_pass
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
OS / ENVIRONMENT

Ubuntu 20.04 Docker Container running on VM. Works without problems on hundreds of linux hosts and hundreds of windows host running Windows Server 2012R2, 2016 and 2019.

STEPS TO REPRODUCE

It can't connect already on initial facts gathering

EXPECTED RESULTS

Sucessful gathering facts

ACTUAL RESULTS
TASK [Gathering Facts] **************************************************************************************************************************************************************************
task path: /config/workspace/ansible/Playbooks/basic_system_windows.yml:3
redirecting (type: modules) ansible.builtin.setup to ansible.windows.setup
Using module file /usr/local/lib/python3.8/dist-packages/ansible_collections/ansible/windows/plugins/modules/setup.ps1
Pipelining is enabled.
<10.176.4.115> ESTABLISH WINRM CONNECTION FOR USER: ansibleusr on PORT 5986 TO 10.176.4.115
<10.176.4.115> WINRM CONNECT: transport=certificate endpoint=https://10.176.4.115:5986/wsman
<10.176.4.115> WINRM CONNECTION ERROR: ('Connection aborted.', OSError("(104, 'ECONNRESET')"))
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into
    return self.recv_into(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into
    return self.recv_into(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 318, in recv_into
    raise SocketError(str(e))
OSError: (104, 'ECONNRESET')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into
    return self.recv_into(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into
    return self.recv_into(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 318, in recv_into
    raise SocketError(str(e))
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(104, 'ECONNRESET')"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ansible/plugins/connection/winrm.py", line 447, in _winrm_connect
    self.shell_id = protocol.open_shell(codepage=65001)  # UTF-8
  File "/usr/local/lib/python3.8/dist-packages/winrm/protocol.py", line 166, in open_shell
    res = self.send_message(xmltodict.unparse(req))
  File "/usr/local/lib/python3.8/dist-packages/winrm/protocol.py", line 243, in send_message
    resp = self.transport.send_message(message)
  File "/usr/local/lib/python3.8/dist-packages/winrm/transport.py", line 334, in send_message
    response = self._send_message_request(prepared_request, message)
  File "/usr/local/lib/python3.8/dist-packages/winrm/transport.py", line 339, in _send_message_request
    response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')"))
fatal: [10.176.4.115]: UNREACHABLE! => {
    "changed": false,
    "msg": "certificate: ('Connection aborted.', OSError(\"(104, 'ECONNRESET')\"))",
    "unreachable": true
}
sandroLuk commented 2 years ago

It seems that the issue affects only certificate login. I made a test with basic auth and it works there. But i still looking for a a solution for the certificate method.

jborean93 commented 2 years ago

The ECONNRESET is a sign that the remote peer had completely shut down the connection for some reason. This can be due to many reasons like:

Unfortunately the server doesn't really indicate what goes wrong, it just kills the connection leading to what you see here. The fact that you said that this is happening only with certificate auth would lead me to think that there's a problem with the server trying to process the certificate offered by the client.

Unfortunately from an Ansible perspective there's not much we can do. What I recommend is to enable debug logging for SChannel on the Windows host https://docs.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/enable-schannel-event-logging. This will hopefuly have Windows log events on the TLS handshake process and potentially indicate why it rejected what the client was sending. You could also look into the WinRM operational logs to try and see if it's logging any errors that might be helpful https://devblogs.microsoft.com/scripting/troubleshoot-winrm-with-powershellpart-1/.

sandroLuk commented 2 years ago

Hi @jborean93, thanks fot the hints, i will check if i can find something.

Have you tested by yourself to login on a win 2022 server via a certificate login and has it worked for you? I'm using the powershell script from the ansible repo (https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1) and it don't works for me on that version. Do you think i should create an issue for this on the main ansible git?

jborean93 commented 2 years ago

I can't say for sure whether I've tested against Server 2022 but I definitely have done it for 2019. The script mentioned just sets up the server with the listeners. It doesn't have anything to do with configuring the certificate mapping and it's not really something that belongs there.

The first step is figuring out why why certificate auth is failing. The first step is to verify that any other auth over HTTPS also works. Regardless of whether it does or does not work checking the SChannel logs to figure out why it may not be working.

hackatoo commented 2 years ago

Any updates here? I have the same issue with the same error. So, on the 2019 and 2016 working fine, while trying 2022 getting this: ansible [core 2.12.4] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/exor/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/exor/.local/lib/python3.8/site-packages/ansible ansible collection location = /home/exor/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] jinja version = 2.10.1 libyaml = True Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /home/exor/12/hosts_new as it did not pass its verify_file() method script declined parsing /home/exor/12/hosts_new as it did not pass its verify_file() method auto declined parsing /home/exor/12/hosts_new as it did not pass its verify_file() method Parsed /home/exor/12/hosts_new inventory source with ini plugin Loading callback plugin minimal of type stdout, v2.0 from /home/exor/.local/lib/python3.8/site-packages/ansible/plugins/callback/minimal.py Attempting to use 'default' callback. Skipping callback 'default', as we already have a stdout callback. Attempting to use 'junit' callback. Attempting to use 'minimal' callback. Skipping callback 'minimal', as we already have a stdout callback. Attempting to use 'oneline' callback. Skipping callback 'oneline', as we already have a stdout callback. Attempting to use 'tree' callback. META: ran handlers redirecting (type: modules) ansible.builtin.win_ping to ansible.windows.win_ping Loading collection ansible.windows from /home/exor/.local/lib/python3.8/site-packages/ansible_collections/ansible/windows Using module file /home/exor/.local/lib/python3.8/site-packages/ansible_collections/ansible/windows/plugins/modules/win_ping.ps1 Pipelining is enabled. <13.40.224.207> ESTABLISH WINRM CONNECTION FOR USER: Tteam on PORT 5986 TO 13.40.224.207 <13.40.224.207> WINRM CONNECT: transport=certificate endpoint=https://13.40.224.207:5986/wsman <13.40.224.207> WINRM CONNECTION ERROR: ('Connection aborted.', OSError("(104, 'ECONNRESET')")) Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse response.begin() File "/usr/lib/python3.8/http/client.py", line 316, in begin version, status, reason = self._read_status() File "/usr/lib/python3.8/http/client.py", line 277, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into return self.recv_into(*args, *kwargs) File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 318, in recv_into raise SocketError(str(e)) OSError: (104, 'ECONNRESET') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen retries = retries.increment( File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise raise value.with_traceback(tb) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse response.begin() File "/usr/lib/python3.8/http/client.py", line 316, in begin version, status, reason = self._read_status() File "/usr/lib/python3.8/http/client.py", line 277, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 328, in recv_into return self.recv_into(args, kwargs) File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 318, in recv_into raise SocketError(str(e)) urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(104, 'ECONNRESET')")) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/exor/.local/lib/python3.8/site-packages/ansible/plugins/connection/winrm.py", line 447, in _winrm_connect self.shell_id = protocol.open_shell(codepage=65001) # UTF-8 File "/usr/lib/python3/dist-packages/winrm/protocol.py", line 157, in open_shell res = self.send_message(xmltodict.unparse(req)) File "/usr/lib/python3/dist-packages/winrm/protocol.py", line 234, in send_message resp = self.transport.send_message(message) File "/usr/lib/python3/dist-packages/winrm/transport.py", line 265, in send_message response = self._send_message_request(prepared_request, message) File "/usr/lib/python3/dist-packages/winrm/transport.py", line 270, in _send_message_request response = self.session.send(prepared_request, timeout=self.read_timeout_sec) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')")) test2022 | UNREACHABLE! => { "changed": false, "msg": "certificate: ('Connection aborted.', OSError(\"(104, 'ECONNRESET')\"))", "unreachable": true }

jborean93 commented 2 years ago

I've actually just recently came across this when trying to test out certificate auth in a GitHub Actions runner which runs on Server 2022.

Unfortunately I was not able to figure out the problem but it seems like the problem was due to some issue with TLS 1.3 (introduced with Server 2022) and certificate authentication. You can try to load the following functions from https://gist.github.com/jborean93/573695261ca50fb0142fa3f4a1a24fcd and run

$binding = Get-HttpSslCert -IPPort 0.0.0.0:5986
$binding | Remove-HttpSslCert
$binding | Add-HttpSslCert -DisableTls13 -DisableHttp2

When testing this in GHA it unfortunately didn't fix my problem for WinRM but testing cert auth in IIS did so you might have better luck. Also this was broken from a native PowerShell client and not just the Python libraries during my testing so not something Ansible/Python specific but some problem on the Windows stack.

hackatoo commented 2 years ago

Seems like the problem was in the default version of TLS which in Windows Server 2022 by default is 1.3 but ansbile/py libraries working with TLS 1.2 only So i've solved the problem by changing SCHANNEL registry which can be found by PATH Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\

I've added the parameter TLS 1.3 and two keys for Client and Server Folder wtih Powershell commands:

New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -Force
New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -Force
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'Enabled' -value '0' –PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'DisabledByDefault' -value '1' –PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'Enabled' -value '0' –PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'DisabledByDefault' -value '1' –PropertyType 'DWORD'

If you need tls 1.3 be enabled just delete the raws which add a rule for Enabled with Value 0 or replace it with Value 1.

When i made this, WINRM cert auth and remote Ansible commands started working fine.

jborean93 commented 2 years ago

Ultimately this seems to be a problem with the TLS stack on the Windows side. As the problem affects the native PowerShell client on Windows the issue needs to be raised with MS.

sandroLuk commented 2 years ago

@jborean93 hm but isn't it on ansibles side to provide support for the newer TLS version 1.3 which seems to be the new standard? I mean when microsoft decides to accept only the newer protocol than that's not a microsoft bug but a security best practice and it would be good if ansible would support that. Or am i missing a point here?

jborean93 commented 2 years ago

Ansible supports TLS 1.3 just fine, the support comes from the builtin ssl lib in Python and I can confirm it works. What doesn’t work is certificate authentication as the server is closing the tunnel being established. When I was testing this I found that not even PowerShell itself can connect using certificate auth which tells me the problem exists on the server end.

If you can confirm that doing certificate auth from a Microsoft client, like PowerShell, works with the same server I’m happy to reopen this and investigate it more. The command to test this is:

Invoke-Command server { 'test' } -CertificateThumbprint $thumbprint

I believe the cert needs to be in the CurrentUser My/Personal store for it to find it by the thumbprint.

Also keep in mind the place where this all fits is in the native OpenSSL library that Python is calling. This is largely out of our control so it may not be something we can fix, or at least through an update from one of the winrm library.

harryoui commented 4 months ago

For anyone else coming here and trying the above Powershell registry commands but are receiving errors: the dash in "-PropertyType" is a unicode dash (U+2013/EN DASH) not ASCII. Here's the same command but without the special symbols:


New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -Force
New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -Force
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'Enabled' -value '0' -PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'DisabledByDefault' -value '1' -PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'Enabled' -value '0' -PropertyType 'DWORD'
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'DisabledByDefault' -value '1' -PropertyType 'DWORD'