Programing

TLS 1.2를 사용하도록 .NET 웹 서비스 업데이트

lottogame 2020. 11. 13. 07:44
반응형

TLS 1.2를 사용하도록 .NET 웹 서비스 업데이트


TLS 1.2를 사용하여 .NET 웹 서비스에서 TLS 1.2를 강제 할 다른 웹 서비스로 연결해야합니다. .NET 4.6은 기본적으로 TLS 1.2를 사용하므로 가장 쉬운 솔루션처럼 들리는 리소스를 찾았습니다. 서버에서 .NET 프레임 워크를 업데이트하고 다시 시작했습니다. IIS에서 .NET 4.6을 사용하여 응용 프로그램 풀을 만들려고했지만 4.0이 유일한 옵션이었습니다. 그런 다음 4.6이 .NET 4.0에 대한 "현재 위치"업데이트이기 때문에 여전히 4.0이라고 표시되는 것을 발견했습니다. 그래서 나는 아마 끝났다고 생각했습니다. 그러나 관련없는 이유로 얻은 오류 페이지에 Microsoft .NET Framework Version:4.0.30319성공적으로 업그레이드하지 않은 것 같습니다. 내 응용 프로그램 풀이 .NET 4.6을 사용하고 있는지 확인하는 방법 또는 일반적으로 TLS 1.2를 사용하는 방법에 대한 포인터가 있습니까?


실제로 TLS 1.2를 허용하기 위해 .NET 웹 서비스를 4.6으로 업그레이드했습니다.

Artem이 말하는 것은 우리가 한 첫 번째 단계입니다. 웹 서비스의 프레임 워크를 4.6으로 다시 컴파일하고 TLS 1.2를 활성화하도록 레지스트리 키를 변경했지만 작동하지 않았습니다. 연결이 여전히 TLS 1.0에있었습니다. 또한 시스템에서 SLL 3.0, TLS 1.0 또는 TLS 1.1을 허용하지 않기를 원했습니다. 다른 웹 서비스에서이를 사용할 수 있습니다. 레지스트리에서 변경 사항을 롤백했습니다.

우리는 실제로 Web.Config 파일을 변경하여 IIS에 "야, 4.6에서 실행 해주세요"라고 알려주었습니다.

다음은 web.config + .NET 4.6의 재 컴파일에 추가 된 변경 사항입니다.

<system.web>
    <compilation targetFramework="4.6"/> <!-- Changed framework 4.0 to 4.6 -->

    <!--Added this httpRuntime -->
    <httpRuntime targetFramework="4.6" />

    <authentication mode="Windows"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>

IIS는 이제 4.6 (명시 적으로 말함)에서 웹 서비스를 실행하고 4.6은 기본적으로 TLS 1.2를 사용하기 때문에 연결이 TLS 1.2로 변경되었습니다.


웹 서비스 클라이언트를 인스턴스화하기 전에 다음 코드를 추가하십시오.

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

또는 TLS 1.1 및 이전 버전과의 역 호환성을 위해 :

System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; 

4.5 이전의 .Net을 사용하는 경우 열거 형에 Tls12가 없으므로 여기에 상태가 명시 적으로 언급 됩니다.

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

필요한 세 단계 :

  1. 레지스트리에 Enabled=0DisabledByDefault=1(전체 경로는 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols) 추가하여 서버 컴퓨터에서 SSL2.0, TLS1.0, TLS1.1을 금지됨으로 명시 적으로 표시합니다 . 자세한 내용은 화면 참조기재

  2. TLS1.21의 단계에 따라 명시 적으로 활성화 하십시오 . Enabled=1DisabledByDefault=0각각을 사용하십시오 .

참고 : 서버 버전 확인 : 프로토콜을 Windows Server 2003지원하지 않습니다.TLS 1.2

  1. TLS1.2위에서 제안한 @John Wu와 같이 앱 수준에서만 활성화 합니다.

    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

이 가이드가 도움이되기를 바랍니다.

@Subbu가 언급했듯이 업데이트 : 공식 가이드


나를 위해 일했습니다.

Step 1: Downloaded and installed the web Installer exe from https://www.microsoft.com/en-us/download/details.aspx?id=48137 on the application server. Rebooted the application server after installation was completed.

Step 2: Added below changes in the web.config

<system.web>
    <compilation targetFramework="4.6"/> <!-- Changed framework 4.0 to 4.6 -->
    <!--Added this httpRuntime -->
    <httpRuntime targetFramework="4.6" />
</system.web>

Step 3: After completing step 1 and 2, it gave an error, "WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)" and to resolve this error, I added below key in appsettings in my web.config file

<appSettings>
      <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>

참고URL : https://stackoverflow.com/questions/45382254/update-net-web-service-to-use-tls-1-2

반응형