Skip to content

Commit 2f69707

Browse files
authored
TLS: Check EKU in X509 chain checks (#2670)
Further hardening following #2665. This is an additional check to match the .NET implementation for TLS cert checks so that we don't treat a cert flagged as non-TLS-server effectively. This ensures that a certificate either doesn't have OIDs here (valid, backwards compatible) or has the server-certificate OID indicating it's valid for consumption over TLS for us. Cheers @bartonjs for the report and info here.
1 parent 60e5d17 commit 2f69707

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/ReleaseNotes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Current package versions:
77
| [![StackExchange.Redis](https://img.shields.io/nuget/v/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis](https://img.shields.io/nuget/vpre/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis MyGet](https://img.shields.io/myget/stackoverflow/vpre/StackExchange.Redis.svg)](https://www.myget.org/feed/stackoverflow/package/nuget/StackExchange.Redis) |
88

99
## Unreleased
10-
No pending/unreleased changes.
10+
- TLS certificate/`TrustIssuer`: Check EKU in X509 chain checks when validating cerificates ([#2670 by NickCraver](https://github.com/StackExchange/StackExchange.Redis/pull/2670))
1111

1212
## 2.7.33
1313

src/StackExchange.Redis/ConfigurationOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ private static RemoteCertificateValidationCallback TrustIssuerCallback(X509Certi
312312
};
313313
}
314314

315+
private static readonly Oid _serverAuthOid = new Oid("1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.1");
316+
315317
private static bool CheckTrustedIssuer(X509Certificate2 certificateToValidate, X509Chain? chainToValidate, X509Certificate2 authority)
316318
{
317319
// Reference:
@@ -322,6 +324,8 @@ private static bool CheckTrustedIssuer(X509Certificate2 certificateToValidate, X
322324
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
323325
chain.ChainPolicy.VerificationTime = chainToValidate?.ChainPolicy?.VerificationTime ?? DateTime.Now;
324326
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0);
327+
// Ensure entended key usage checks are run and that we're observing a server TLS certificate
328+
chain.ChainPolicy.ApplicationPolicy.Add(_serverAuthOid);
325329

326330
chain.ChainPolicy.ExtraStore.Add(authority);
327331
try

0 commit comments

Comments
 (0)