Skip to content

Commit

Permalink
Revert "Treat warnings as errors (#3166)"
Browse files Browse the repository at this point in the history
This reverts commit bfc7b6b.
  • Loading branch information
keegan-caruso authored Dec 31, 2024
1 parent bfc7b6b commit 3cfaecf
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 22 deletions.
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<LangVersion>13</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == 'NET6_0_OR_GREATER'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,18 @@ public Task LoadIfNeededAsync(CredentialDescription credentialDescription, Crede

internal static X509Certificate2 LoadFromBase64Encoded(string certificateBase64, X509KeyStorageFlags x509KeyStorageFlags)
{
#pragma warning disable SYSLIB0057 // Type or member is obsolete
return new X509Certificate2(
Convert.FromBase64String(certificateBase64),
(string?)null,
x509KeyStorageFlags);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
}

internal static X509Certificate2 LoadFromBase64Encoded(string certificateBase64, string password, X509KeyStorageFlags x509KeyStorageFlags)
{
#pragma warning disable SYSLIB0057 // Type or member is obsolete
return new X509Certificate2(
Convert.FromBase64String(certificateBase64),
password,
x509KeyStorageFlags);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ private static X509Certificate2 LoadFromPath(
{
X509KeyStorageFlags x509KeyStorageFlags = CertificateLoaderHelper.DetermineX509KeyStorageFlag();

#pragma warning disable SYSLIB0057 // Type or member is obsolete
return new X509Certificate2(
certificateFileName,
password,
x509KeyStorageFlags);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ public async Task LoadIfNeededAsync(CredentialDescription credentialDescription,
// Return a certificate with only the public key if the private key is not exportable.
if (certificate.Policy?.Exportable != true)
{
#pragma warning disable SYSLIB0057 // Type or member is obsolete
return new X509Certificate2(
certificate.Cer,
(string?)null,
x509KeyStorageFlags);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
}

// Parse the secret ID and version to retrieve the private key.
Expand Down
2 changes: 0 additions & 2 deletions tests/E2E Tests/TokenAcquirerTests/CertificateRotationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ private X509Certificate2 CreateSelfSignedCertificateAddAddToCertStore(string cer
var cert = req.CreateSelfSigned(notBefore.HasValue ? notBefore.Value : DateTimeOffset.Now, expiry);

byte[] bytes = cert.Export(X509ContentType.Pfx, (string?)null);
#pragma warning disable SYSLIB0057 // Type or member is obsolete
X509Certificate2 certWithPrivateKey = new(bytes);
#pragma warning restore SYSLIB0057 // Type or member is obsolete

// Add it to the local cert store.
X509Store x509Store = new(StoreName.My, StoreLocation.CurrentUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public void TestFromStoreWithThumbprint(string certificateThumbprint, StoreLocat
[Fact]
public void TestFromCertificate()
{
#pragma warning disable SYSLIB0057 // Type or member is obsolete
using X509Certificate2 certificate2 = new([]);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
using X509Certificate2 certificate2 = new X509Certificate2(new byte[0]);
CertificateDescription certificateDescription =
CertificateDescription.FromCertificate(certificate2);
}
Expand Down
8 changes: 2 additions & 6 deletions tests/Microsoft.Identity.Web.Test/MsAuth10AtPopTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ public void MsAuth10AtPop_ThrowsWithNullPopKeyTest()
{
// Arrange
IConfidentialClientApplication app = CreateBuilder();
#pragma warning disable SYSLIB0057 // Type or member is obsolete
using X509Certificate2 clientCertificate = new([]);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
var clientCertificate = new X509Certificate2(new byte[0]);
var jwkClaim = "jwk_claim";
var clientId = "client_id";

Expand All @@ -101,9 +99,7 @@ public void MsAuth10AtPop_ThrowsWithNullJwkClaimTest()
{
// Arrange
IConfidentialClientApplication app = CreateBuilder();
#pragma warning disable SYSLIB0057 // Type or member is obsolete
using X509Certificate2 clientCertificate = new([]);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
var clientCertificate = new X509Certificate2(new byte[0]);
var popPublicKey = "pop_key";
var clientId = "client_id";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override HttpContext CreateHttpContext()
[Fact]
public async Task TokenValidated_MissingScopesAndRoles_AuthenticationFailsAsync()
{
Assert.True(_tokenContext.Result!.Succeeded);
Assert.True(_tokenContext.Result.Succeeded);
await _jwtEvents.TokenValidated(_tokenContext);
Assert.False(_tokenContext.Result.Succeeded);
}
Expand All @@ -68,7 +68,7 @@ protected override HttpContext CreateHttpContext()
[Fact]
public async Task TokenValidated_WithScopesAndRoles_AuthenticationSucceedsAsync()
{
Assert.True(_tokenContext.Result!.Succeeded);
Assert.True(_tokenContext.Result.Succeeded);
await _jwtEvents.TokenValidated(_tokenContext);
Assert.True(_tokenContext.Result.Succeeded);
}
Expand Down

0 comments on commit 3cfaecf

Please sign in to comment.