Kaganapan
Mar 17, 9 PM - Mar 21, 10 AM
Sumali sa serye ng meetup upang bumuo ng mga scalable AI solusyon batay sa mga kaso ng paggamit ng tunay na mundo sa mga kapwa developer at eksperto.
Magparehistro naHindi na suportado ang browser na ito.
Mag-upgrade sa Microsoft Edge para samantalahin ang mga pinakabagong tampok, update sa seguridad, at teknikal na suporta.
Property | Value |
---|---|
Rule ID | CA5398 |
Title | Avoid hardcoded SslProtocols values |
Category | Security |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default in .NET 9 | No |
This rule fires when either of the following conditions are met:
Safe values are:
Transport Layer Security (TLS) secures communication between computers, most commonly with Hypertext Transfer Protocol Secure (HTTPS). Protocol versions TLS 1.0 and TLS 1.1 are deprecated, while TLS 1.2 and TLS 1.3 are current. In the future, TLS 1.2 and TLS 1.3 may be deprecated. To ensure that your application remains secure, avoid hardcoding a protocol version. For more information, see Transport Layer Security (TLS) best practices with .NET Framework.
Don't hardcode TLS protocol versions.
It's safe to suppress a warning if you need to connect to a legacy service that can't be upgraded to use future TLS protocol versions.
If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable CA5398
// The code that's violating the rule is on this line.
#pragma warning restore CA5398
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.CA5398.severity = none
For more information, see How to suppress code analysis warnings.
using System;
using System.Security.Authentication;
public class ExampleClass
{
public void ExampleMethod()
{
// CA5398 violation
SslProtocols sslProtocols = SslProtocols.Tls12;
}
}
Imports System
Imports System.Security.Authentication
Public Class TestClass
Public Function ExampleMethod() As SslProtocols
' CA5398 violation
Return SslProtocols.Tls12
End Function
End Class
using System;
using System.Security.Authentication;
public class ExampleClass
{
public SslProtocols ExampleMethod()
{
// CA5398 violation
return (SslProtocols) 3072; // TLS 1.2
}
}
Imports System
Imports System.Security.Authentication
Public Class TestClass
Public Function ExampleMethod() As SslProtocols
' CA5398 violation
Return CType(3072, SslProtocols) ' TLS 1.2
End Function
End Class
using System;
using System.Security.Authentication;
public class TestClass
{
public void Method()
{
// Let the operating system decide what TLS protocol version to use.
// See https://learn.microsoft.com/dotnet/framework/network-programming/tls
SslProtocols sslProtocols = SslProtocols.None;
}
}
Imports System
Imports System.Security.Authentication
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
Dim sslProtocols As SslProtocols = SslProtocols.None
End Sub
End Class
CA5364: Do not use deprecated security protocols
Feedback sa .NET
Ang .NET ay isang open source na project. Pumili ng link para magbibigay ng feedback:
Kaganapan
Mar 17, 9 PM - Mar 21, 10 AM
Sumali sa serye ng meetup upang bumuo ng mga scalable AI solusyon batay sa mga kaso ng paggamit ng tunay na mundo sa mga kapwa developer at eksperto.
Magparehistro na