Share via


CA5364: 사용되지 않는 보안 프로토콜을 사용하지 마세요.

속성
규칙 ID CA5364
타이틀 사용되지 않는 보안 프로토콜을 사용하지 마세요.
범주 보안
수정 사항이 주요 변경인지 여부 주요 변경 아님
.NET 8에서 기본적으로 사용 아니요

원인

이 규칙은 다음 조건 중 하나가 충족될 때 발생합니다.

사용되지 않는 값:

  • Ssl3
  • Tls
  • Tls10
  • Tls11

규칙 설명

TLS(전송 계층 보안)는 가장 일반적으로 HTTPS(Hypertext Transfer Protocol Secure)를 사용하여 컴퓨터 간의 통신을 보호합니다. TLS의 이전 프로토콜 버전은 TLS 1.2 및 TLS 1.3보다 안전하지 않으며 새로운 취약성이 있을 가능성이 큽니다. 위험을 최소화하려면 이전 프로토콜 버전을 사용하지 마세요. 사용되지 않는 프로토콜 버전을 식별하고 제거하는 방법에 대한 지침은 TLS 1.0 문제 해결, 2판을 참조하세요.

위반 문제를 해결하는 방법

사용되지 않는 TLS 프로토콜 버전을 사용하지 마세요.

경고를 표시하지 않는 경우

다음과 같은 경우 이 경고를 표시하지 않을 수 있습니다.

  • 사용되지 않는 프로토콜 버전에 대한 참조가 사용되지 않는 버전을 사용하도록 설정하는 데 사용되지 않습니다.
  • 보안 TLS 구성을 사용하기 위해 업그레이드할 수 없는 레거시 서비스에 연결해야 합니다.

경고 표시 안 함

단일 위반만 표시하지 않으려면 원본 파일에 전처리기 지시문을 추가하여 규칙을 사용하지 않도록 설정한 후 다시 사용하도록 설정합니다.

#pragma warning disable CA5364
// The code that's violating the rule is on this line.
#pragma warning restore CA5364

파일, 폴더 또는 프로젝트에 대한 규칙을 사용하지 않도록 설정하려면 구성 파일에서 심각도를 none으로 설정합니다.

[*.{cs,vb}]
dotnet_diagnostic.CA5364.severity = none

자세한 내용은 방법: 코드 분석 경고 표시 안 함을 참조하세요.

의사 코드 예제

열거형 이름 위반

using System;
using System.Net;

public class ExampleClass
{
    public void ExampleMethod()
    {
        // CA5364 violation
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
    }
}
Imports System
Imports System.Net

Public Class TestClass
    Public Sub ExampleMethod()
        ' CA5364 violation
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
    End Sub
End Class

정수 값 위반

using System;
using System.Net;

public class ExampleClass
{
    public void ExampleMethod()
    {
        // CA5364 violation
        ServicePointManager.SecurityProtocol = (SecurityProtocolType) 768;    // TLS 1.1
    }
}
Imports System
Imports System.Net

Public Class TestClass
    Public Sub ExampleMethod()
        ' CA5364 violation
        ServicePointManager.SecurityProtocol = CType(768, SecurityProtocolType)   ' TLS 1.1
    End Sub
End Class

솔루션

using System;
using System.Net;

public class TestClass
{
    public void TestMethod()
    {
        // Let the operating system decide what TLS protocol version to use.
        // See https://learn.microsoft.com/dotnet/framework/network-programming/tls
    }
}
Imports System
Imports System.Net

Public Class TestClass
    Public Sub ExampleMethod()
        ' Let the operating system decide what TLS protocol version to use.
        ' See https://learn.microsoft.com/dotnet/framework/network-programming/tls
    End Sub
End Class

CA5386: SecurityProtocolType 값 하드코딩 방지

CA5397: 사용되지 않는 SslProtocols 값을 사용하지 마세요.

CA5398: 하드 코딩된 SslProtocols 값 방지