Skip to content

Commit 27a737c

Browse files
committed
Addressing review feedback
1 parent d4b46d6 commit 27a737c

File tree

5 files changed

+72
-14
lines changed

5 files changed

+72
-14
lines changed

docs/code-quality/ca5361.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "CA5361: Do Not Disable SChannel Use of Strong Crypto"
2+
title: "CA5361: Do not disable SChannel use of strong crypto"
33
ms.date: 07/10/2019
44
ms.topic: reference
55
author: dotpaul
@@ -14,7 +14,7 @@ f1_keywords:
1414
- "CA5361"
1515
- "DoNotSetSwitch"
1616
---
17-
# CA5361: Do Not Disable SChannel Use of Strong Crypto
17+
# CA5361: Do not disable SChannel use of strong crypto
1818

1919
|||
2020
|-|-|
@@ -34,12 +34,12 @@ Setting `Switch.System.Net.DontEnableSchUseStrongCrypto` to `true` weakens the c
3434
## How to fix violations
3535

3636
- If your application targets .NET Framework v4.6 or later, you can either remove the <xref:System.AppContext.SetSwitch%2A?displayProperty=nameWithType> method call, or set the switch's value to `false`.
37-
- If your application targets .NET Framework earlier than v4.6, and runs on .NET Framework v4.6 or later, set the switch's value to `false`.
37+
- If your application targets .NET Framework earlier than v4.6 and runs on .NET Framework v4.6 or later, set the switch's value to `false`.
3838
- Otherwise, refer to [Transport Layer Security (TLS) best practices with the .NET Framework](/dotnet/framework/network-programming/tls) for mitigations.
3939

4040
## When to suppress warnings
4141

42-
You can suppress this warning if you need to connect to a legacy service, which can't be upgraded to use secure TLS configurations.
42+
You can suppress this warning if you need to connect to a legacy service that can't be upgraded to use secure TLS configurations.
4343

4444
## Pseudo-code examples
4545

docs/code-quality/ca5364.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "CA5364: Do Not Use Deprecated Security Protocols"
2+
title: "CA5364: Do not use deprecated security protocols"
33
ms.date: 07/10/2019
44
ms.topic: reference
55
author: dotpaul
@@ -14,7 +14,7 @@ f1_keywords:
1414
- "CA5364"
1515
- "DoNotUseDeprecatedSecurityProtocols"
1616
---
17-
# CA5364: Do Not Use Deprecated Security Protocols
17+
# CA5364: Do not use deprecated security protocols
1818

1919
|||
2020
|-|-|
@@ -25,6 +25,7 @@ f1_keywords:
2525

2626
## Cause
2727

28+
This rule fires when either of the following conditions are met:
2829
- A deprecated <xref:System.Net.SecurityProtocolType?displayProperty=nameWithType> value was referenced.
2930
- An integer value representing a deprecated value was assigned to a <xref:System.Net.SecurityProtocolType> variable.
3031

@@ -44,8 +45,9 @@ Don't use deprecated TLS protocol versions.
4445

4546
## When to suppress warnings
4647

47-
- It's safe to suppress this warning if the reference to the deprecated protocol version isn't being used to enable a deprecated version.
48-
- You can suppress this warning if you need to connect to a legacy service, which can't be upgraded to use secure TLS configurations.
48+
It's safe to suppress this warning if:
49+
- The reference to the deprecated protocol version isn't being used to enable a deprecated version.
50+
- You need to connect to a legacy service that can't be upgraded to use secure TLS configurations.
4951

5052
## Pseudo-code examples
5153

@@ -77,6 +79,34 @@ Public Class TestClass
7779
End Class
7880
```
7981

82+
### Violation
83+
84+
```csharp
85+
using System;
86+
using System.Net;
87+
88+
public class ExampleClass
89+
{
90+
public void ExampleMethod()
91+
{
92+
// CA5364 violation
93+
ServicePointManager.SecurityProtocol = (SecurityProtocolType) 768; // TLS 1.1
94+
}
95+
}
96+
```
97+
98+
```vb
99+
Imports System
100+
Imports System.Net
101+
102+
Public Class TestClass
103+
Public Sub ExampleMethod()
104+
' CA5364 violation
105+
ServicePointManager.SecurityProtocol = CType(768, SecurityProtocolType) ' TLS 1.1
106+
End Sub
107+
End Class
108+
```
109+
80110
### Solution
81111

82112
```csharp

docs/code-quality/ca5378.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ Setting `Switch.System.ServiceModel.DisableUsingServicePointManagerSecurityProto
3434
## How to fix violations
3535

3636
- If your application targets .NET Framework v4.7 or later, you can either remove the <xref:System.AppContext.SetSwitch%2A?displayProperty=nameWithType> method call, or set the switch's value to `false`.
37-
- If your application targets .NET Framework v4.6.2 or earlier, and runs on .NET Framework v4.7 or later, set the switch's value to `false`.
37+
- If your application targets .NET Framework v4.6.2 or earlier and runs on .NET Framework v4.7 or later, set the switch's value to `false`.
3838
- Otherwise, refer to [Transport Layer Security (TLS) best practices with the .NET Framework](/dotnet/framework/network-programming/tls) for mitigations.
3939

4040
## When to suppress warnings
4141

42-
You can suppress this warning if you need to connect to a legacy service, which can't be upgraded to use secure TLS configurations.
42+
You can suppress this warning if you need to connect to a legacy service that can't be upgraded to use secure TLS configurations.
4343

4444
## Pseudo-code examples
4545

docs/code-quality/ca5386.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ Transport Layer Security (TLS) secures communication between computers, most com
3838

3939
## How to fix violations
4040

41-
Don't use hardcode TLS protocol versions.
41+
Don't hardcode TLS protocol versions.
4242

4343
## When to suppress warnings
4444

45-
You can suppress this warning if you need to connect to a legacy service, which can't be upgraded to use secure TLS configurations.
45+
You can suppress this warning if your application targets .NET Framework v4.6.2 or earlier and may run on a computer that has insecure defaults.
4646

4747
## Pseudo-code examples
4848

@@ -74,6 +74,34 @@ Public Class TestClass
7474
End Class
7575
```
7676

77+
### Violation
78+
79+
```csharp
80+
using System;
81+
using System.Net;
82+
83+
public class ExampleClass
84+
{
85+
public void ExampleMethod()
86+
{
87+
// CA5386 violation
88+
ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072; // TLS 1.2
89+
}
90+
}
91+
```
92+
93+
```vb
94+
Imports System
95+
Imports System.Net
96+
97+
Public Class TestClass
98+
Public Sub ExampleMethod()
99+
' CA5386 violation
100+
ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType) ' TLS 1.2
101+
End Sub
102+
End Class
103+
```
104+
77105
### Solution
78106

79107
```csharp

docs/code-quality/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,9 @@
690690
href: ca3077-insecure-processing-in-api-design-xml-document-and-xml-text-reader.md
691691
- name: "CA3147: Mark verb handlers with ValidateAntiForgeryToken"
692692
href: ca3147-mark-verb-handlers-with-validateantiforgerytoken.md
693-
- name: "CA5361: Do Not Disable SChannel Use of Strong Crypto"
693+
- name: "CA5361: Do not disable SChannel use of strong crypto"
694694
href: ca5361.md
695-
- name: "CA5364: Do Not Use Deprecated Security Protocols"
695+
- name: "CA5364: Do not use deprecated security protocols"
696696
href: ca5364.md
697697
- name: "CA5378: Do not disable ServicePointManagerSecurityProtocols"
698698
href: ca5378.md

0 commit comments

Comments
 (0)