Could not create SSL/TLS secure channel while trying to search for NuGet packages

When I press on "Browse" tab on NuGet packages in Visual Studio, it says "Error occurred" with an error message of

[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json.
  An error occurred while sending the request.
  The request was aborted: Could not create SSL/TLS secure channel.

I have been using Visual Studio and NuGet for a long time and NuGet was working a few days ago. Can someone figure out why this is happening and what I can do to solve it?

Visual Studio 2017 version: 15.9.17


NuGet has permanently removed support for TLS 1.0 and 1.1.

Ensure your system uses TLS 1.2.

Run the following commands to enable TLS 1.2 support if it is disabled:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64