Skip to content

Commit

Permalink
Update dotnet 9 in gh pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Caruso committed Aug 14, 2024
1 parent e8605c2 commit c920979
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Setup .NET 9.0.x
uses: actions/[email protected]
with:
dotnet-version: 9.0.100-preview.4.24267.66
dotnet-version: 9.0.100-preview.7.24407.12

- name: Run the tests
run: dotnet test Wilson.sln
Expand Down
4 changes: 2 additions & 2 deletions build/template-Build-run-tests-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ steps:
- task: UseDotNet@2
displayName: 'Use .Net Core SDK 9.x'
inputs:
version: 9.0.100-preview.4.24267.66
version: 9.0.100-preview.7.24407.12
includePreviewVersions: true
condition: eq(variables['TargetNet9'], 'True')

Expand Down Expand Up @@ -174,7 +174,7 @@ steps:
- task: securedevelopmentteam.vss-secure-development-tools.build-task-uploadtotsa.TSAUpload@2
displayName: 'TSA upload to Codebase: WILSON Stamp: Azure'
inputs:
GdnPublishTsaOnboard: false
GdnPublishTsaOnboard: false
GdnPublishTsaConfigFile: '$(Build.SourcesDirectory)/build/tsaConfig.json'
continueOnError: true
condition: and(succeeded(), eq(variables['PipelineType'], 'legacy'))
Expand Down
54 changes: 54 additions & 0 deletions test/Microsoft.IdentityModel.TestUtils/X509Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography.X509Certificates;

namespace Microsoft.IdentityModel.TestUtils
{
public static class X509Helper
{
public static X509Certificate2 ConvertToX509Certificate(string base64Data)
{
var base64Bytes = Convert.FromBase64String(base64Data);

#if NET9_0_OR_GREATER
return X509CertificateLoader.LoadCertificate(base64Bytes);
#else
return new X509Certificate2(base64Bytes);
#endif
}

public static X509Certificate2 ConvertToX509Certificate(string base64Data, SecureString securePassword, X509KeyStorageFlags flags = X509KeyStorageFlags.DefaultKeySet)
{
var password = ConvertFromSecureString(securePassword);
return ConvertToX509Certificate(base64Data, password, flags);
}

public static X509Certificate2 ConvertToX509Certificate(string base64Data, string password, X509KeyStorageFlags flags = X509KeyStorageFlags.DefaultKeySet)
{
var base64Bytes = Convert.FromBase64String(base64Data);
#if NET9_0_OR_GREATER
return X509CertificateLoader.LoadPkcs12(base64Bytes, password, flags);
#else
return new X509Certificate2(base64Bytes, password);
#endif
}

private static string ConvertFromSecureString(SecureString secureString)
{
IntPtr valuePtr = IntPtr.Zero;
try
{
valuePtr = Marshal.SecureStringToGlobalAllocUnicode(secureString);
return Marshal.PtrToStringUni(valuePtr);
}
finally
{
Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
}
}
}
}

0 comments on commit c920979

Please sign in to comment.