Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ inputs:
default: "ice.proj"
type: string

msbuild_command:
description: "The msbuild command to use"
default: "msbuild /m"
type: string

build_cpp_and_python:
description: "Build C++ and Python"
type: choice
Expand Down Expand Up @@ -67,6 +72,6 @@ runs:

- name: Build
working-directory: ${{ inputs.working_directory }}
run: msbuild /m ${{ inputs.build_flags }} ${{ inputs.msbuild_project }}
run: ${{ inputs.msbuild_command }} ${{ inputs.build_flags }} ${{ inputs.msbuild_project }}
shell: powershell
if: runner.os == 'Windows'
16 changes: 14 additions & 2 deletions .github/actions/setup-dotnet/action.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both .NET 8 and .NET 10 for these builds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Ice assemblies always target .NET 8, only the tests are built with .NET 10 target framework.

Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
name: Setup .NET

inputs:
include_net10:
description: "Include .NET 10"
default: "false"

runs:
using: "composite"
steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
dotnet-version: 8.0.x

- name: Setup .NET 10
if: inputs.include_net10 == 'true'
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@ jobs:
build_cpp_and_python: true
build_android_controller: true

# .NET 10.0
- os: ubuntu-24.04
config: ".NET10"
working_directory: "csharp"
net_target_framework: "net10.0"
test_flags: "--target-framework=net10.0"
build_cpp_and_python: true

- os: windows-2025
config: ".NET10"
working_directory: "csharp"
msbuild_command: "dotnet msbuild"
build_flags: "/p:Platform=x64"
msbuild_project: "msbuild/ice.proj"
net_target_framework: "net10.0"
test_flags: "--target-framework=net10.0"
build_cpp_and_python: true

- os: macos-26
config: ".NET10"
working_directory: "csharp"
net_target_framework: "net10.0"
test_flags: "--target-framework=net10.0"
build_cpp_and_python: true

runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand All @@ -133,6 +158,8 @@ jobs:

- name: Setup .NET
uses: ./.github/actions/setup-dotnet
with:
include_net10: ${{ matrix.net_target_framework == 'net10.0' }}

- name: Setup Java
uses: ./.github/actions/setup-java
Expand Down Expand Up @@ -183,6 +210,12 @@ jobs:
echo "EnableAnalysis=true" >> $env:GITHUB_ENV
shell: pwsh

- name: .NET Target Framework
if: matrix.net_target_framework == 'net10.0'
run: |
echo "AppTargetFramework=net10.0" >> $env:GITHUB_ENV
shell: pwsh

- name: Build ${{ matrix.config }} on ${{ matrix.os }}
uses: ./.github/actions/build
timeout-minutes: 90
Expand All @@ -191,6 +224,7 @@ jobs:
build_cpp_and_python: ${{ matrix.build_cpp_and_python || false }}
build_android_controller: ${{ matrix.build_android_controller || false }}
build_flags: ${{ matrix.build_flags || '' }}
msbuild_command: ${{ matrix.msbuild_command || 'msbuild /m' }}
msbuild_project: ${{ matrix.msbuild_project || 'ice.proj' }}

- name: Install testing dependencies from pip
Expand Down
3 changes: 0 additions & 3 deletions csharp/msbuild/CodeAnalysis.Src.globalconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
global_level = 110
is_global = true

# CA1515: Because an application's API isn't typically referenced from outside the assembly, types can be made internal
dotnet_diagnostic.CA1515.severity = none

# CA1849: Call async methods when in an async method
dotnet_diagnostic.CA1849.severity = none

Expand Down
3 changes: 3 additions & 0 deletions csharp/msbuild/CodeAnalysis.Tests.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ dotnet_diagnostic.CA1016.severity = none

# CA2008: Do not create tasks without passing a TaskScheduler
dotnet_diagnostic.CA2008.severity = none

# CA1515: Because an application's API isn't typically referenced from outside the assembly, types can be made internal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You moved this rule because you were getting this warning for tests too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes with .NET 10 this is enabled by default, I want to fix this in a separate PR.

dotnet_diagnostic.CA1515.severity = none
6 changes: 2 additions & 4 deletions csharp/src/Ice/SSL/SSLEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ internal void traceStream(SslStream stream, string connInfo)
s.Append("\nencrypted = " + (stream.IsEncrypted ? "yes" : "no"));
s.Append("\nsigned = " + (stream.IsSigned ? "yes" : "no"));
s.Append("\nmutually authenticated = " + (stream.IsMutuallyAuthenticated ? "yes" : "no"));
s.Append("\nhash algorithm = " + stream.HashAlgorithm + "/" + stream.HashStrength);
s.Append("\ncipher algorithm = " + stream.CipherAlgorithm + "/" + stream.CipherStrength);
s.Append("\nkey exchange algorithm = " + stream.KeyExchangeAlgorithm + "/" + stream.KeyExchangeStrength);
s.Append("\ncipher = " + stream.NegotiatedCipherSuite);
s.Append("\nprotocol = " + stream.SslProtocol);
_logger.trace(_securityTraceCategory, s.ToString());
}
Expand Down Expand Up @@ -337,7 +335,7 @@ private static X509Certificate2Collection findCertificates(
{
try
{
store = new X509Store((StoreName)Enum.Parse(typeof(StoreName), name, true), storeLocation);
store = new X509Store(Enum.Parse<StoreName>(name, true), storeLocation);
}
catch (ArgumentException)
{
Expand Down
4 changes: 2 additions & 2 deletions csharp/src/Ice/SSL/TransceiverI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public int initialize(Ice.Internal.Buffer readBuffer, Ice.Internal.Buffer writeB
Debug.Assert(_sslStream.IsAuthenticated);
_authenticated = true;

_cipher = _sslStream.CipherAlgorithm.ToString();
_cipher = _sslStream.NegotiatedCipherSuite.ToString();
_instance.verifyPeer((ConnectionInfo)getInfo(_incoming, _adapterName, connectionId: ""), ToString());

if (_instance.securityTraceLevel() >= 1)
Expand Down Expand Up @@ -422,7 +422,7 @@ private void finishAuthenticate()
// If authentication fails the task throws AuthenticationException.
_writeResult.Wait();
_verified = true;
_cipher = _sslStream.CipherAlgorithm.ToString();
_cipher = _sslStream.NegotiatedCipherSuite.ToString();
}
catch (AggregateException ex)
{
Expand Down
4 changes: 1 addition & 3 deletions csharp/src/Ice/UtilInternal/StringUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,7 @@ public static bool match(string s, string pat, bool emptyMatch)
//
// Make sure end of the strings match
//
if (!s[endIndex..].Equals(
pat.Substring(beginIndex + 1, pat.Length - beginIndex - 1),
StringComparison.Ordinal))
if (!s[endIndex..].Equals(pat[(beginIndex + 1)..], StringComparison.Ordinal))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/iceboxnet/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace IceBox;

public static class Server
internal static class Server
{
private static void usage()
{
Expand Down
22 changes: 14 additions & 8 deletions csharp/test/IceSSL/configuration/AllTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public static Test.ServerFactoryPrx allTests(Test.TestHelper helper, string defa
//
string caCert1File = defaultDir + "/ca1/ca1_cert.pem";
string caCert2File = defaultDir + "/ca2/ca2_cert.pem";
using var caCert1 = new X509Certificate2(caCert1File);
using var caCert2 = new X509Certificate2(caCert2File);
using X509Certificate2 caCert1 = X509CertificateLoader.LoadCertificateFromFile(caCert1File);
using X509Certificate2 caCert2 = X509CertificateLoader.LoadCertificateFromFile(caCert2File);

var store = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);
bool isAdministrator = false;
Expand Down Expand Up @@ -268,11 +268,14 @@ public static Test.ServerFactoryPrx allTests(Test.TestHelper helper, string defa
ServerPrx server = fact.createServer(d);
try
{
using var clientCert = new X509Certificate2(defaultDir + "/ca1/client.p12", "password");
using X509Certificate2 clientCert =
X509CertificateLoader.LoadPkcs12FromFile(defaultDir + "/ca1/client.p12", "password");
server.checkCert(clientCert.Subject, clientCert.Issuer);

using var serverCert = new X509Certificate2(defaultDir + "/ca1/server.p12", "password");
using var caCert = new X509Certificate2(defaultDir + "/ca1/ca1_cert.pem");
using X509Certificate2 serverCert =
X509CertificateLoader.LoadPkcs12FromFile(defaultDir + "/ca1/server.p12", "password");
using X509Certificate2 caCert =
X509CertificateLoader.LoadCertificateFromFile(defaultDir + "/ca1/ca1_cert.pem");

var info = (Ice.SSL.ConnectionInfo)server.ice_getConnection().getInfo();
test(info.certs.Length == 1);
Expand All @@ -295,7 +298,8 @@ public static Test.ServerFactoryPrx allTests(Test.TestHelper helper, string defa
server = fact.createServer(d);
try
{
using var clientCert = new X509Certificate2(defaultDir + "/ca1/client.p12", "password");
using X509Certificate2 clientCert =
X509CertificateLoader.LoadPkcs12FromFile(defaultDir + "/ca1/client.p12", "password");
server.checkCert(clientCert.Subject, clientCert.Issuer);
}
catch (Exception ex)
Expand Down Expand Up @@ -1496,7 +1500,8 @@ public static Test.ServerFactoryPrx allTests(Test.TestHelper helper, string defa
{
foreach (string certPath in certificates)
{
using var cert = new X509Certificate2(defaultDir + certPath, "password", storageFlags);
using X509Certificate2 cert =
X509CertificateLoader.LoadPkcs12FromFile(defaultDir + certPath, "password", storageFlags);
certStore.Add(cert);
}

Expand Down Expand Up @@ -1558,7 +1563,8 @@ public static Test.ServerFactoryPrx allTests(Test.TestHelper helper, string defa
{
foreach (string certPath in certificates)
{
using var cert = new X509Certificate2(defaultDir + certPath, "password");
using X509Certificate2 cert =
X509CertificateLoader.LoadPkcs12FromFile(defaultDir + certPath, "password");
certStore.Remove(cert);
}
certStore.Close();
Expand Down
47 changes: 27 additions & 20 deletions csharp/test/IceSSL/configuration/PlatformTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ private static void clientValidatesServerUsingValidationCallback(TestHelper help
{
Console.Out.Write("client validates server certificate using validation callback... ");
Console.Out.Flush();
using var serverCertificate =
new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand Down Expand Up @@ -85,8 +85,8 @@ private static void clientRejectServerUsingValidationCallback(TestHelper helper,
{
Console.Out.Write("client rejects server certificate using validation callback... ");
Console.Out.Flush();
using var serverCertificate =
new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand Down Expand Up @@ -116,8 +116,8 @@ private static void clientRejectServerUsingDefaultValidationCallback(TestHelper
{
Console.Out.Write("client rejects server certificate using default validation callback... ");
Console.Out.Flush();
using var serverCertificate =
new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand All @@ -143,10 +143,10 @@ private static void serverValidatesClientUsingValidationCallback(TestHelper help
{
Console.Out.Write("server validates client certificate using validation callback... ");
Console.Out.Flush();
using var serverCertificate =
new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using var clientCertificate =
new X509Certificate2(Path.Combine(certificatesPath, "ca1/client.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
using X509Certificate2 clientCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "client.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand Down Expand Up @@ -176,8 +176,10 @@ private static void serverRejectsClientUsingValidationCallback(TestHelper helper
{
Console.Out.Write("server rejects client certificate using validation callback... ");
Console.Out.Flush();
using var serverCertificate = new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using var clientCertificate = new X509Certificate2(Path.Combine(certificatesPath, "ca1/client.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
using X509Certificate2 clientCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "client.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand Down Expand Up @@ -213,8 +215,10 @@ private static void serverRejectsClientUsingDefaultValidationCallback(TestHelper
{
Console.Out.Write("server rejects client certificate using default validation callback... ");
Console.Out.Flush();
using var serverCertificate = new X509Certificate2(Path.Combine(certificatesPath, "ca1/server.p12"), "password");
using var clientCertificate = new X509Certificate2(Path.Combine(certificatesPath, "ca1/client.p12"), "password");
using X509Certificate2 serverCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "server.p12"), "password");
using X509Certificate2 clientCertificate =
X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(certificatesPath, "ca1", "client.p12"), "password");
var serverOptions = new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
Expand Down Expand Up @@ -250,14 +254,15 @@ private sealed class ServerState : IDisposable
{
public X509Certificate2 Certificate { get; private set; }

public ServerState(string certificatePath) => Certificate = new X509Certificate2(certificatePath, "password");
public ServerState(string certificatePath) =>
Certificate = X509CertificateLoader.LoadPkcs12FromFile(certificatePath, "password");

public void Dispose() => Certificate?.Dispose();

public void reloadCertificate(string certificatePath)
{
Certificate?.Dispose();
Certificate = new X509Certificate2(certificatePath, "password");
Certificate = X509CertificateLoader.LoadPkcs12FromFile(certificatePath, "password");
}
}

Expand All @@ -266,10 +271,12 @@ private static void serverHotCertificateReload(TestHelper helper, string certifi
Console.Out.Write("server hot certificate reload... ");
Console.Out.Flush();

using var trustedRootCertificatesCA1 = new X509Certificate2(Path.Combine(certificatesPath, "ca1/ca1_cert.pem"));
using var trustedRootCertificatesCA2 = new X509Certificate2(Path.Combine(certificatesPath, "ca2/ca2_cert.pem"));
using X509Certificate2 trustedRootCertificatesCA1 =
X509CertificateLoader.LoadCertificateFromFile(Path.Combine(certificatesPath, "ca1", "ca1_cert.pem"));
using X509Certificate2 trustedRootCertificatesCA2 =
X509CertificateLoader.LoadCertificateFromFile(Path.Combine(certificatesPath, "ca2", "ca2_cert.pem"));

using var serverState = new ServerState(Path.Combine(certificatesPath, "ca1/server.p12"));
using var serverState = new ServerState(Path.Combine(certificatesPath, "ca1", "server.p12"));

var serverOptions = new SslServerAuthenticationOptions
{
Expand Down Expand Up @@ -310,7 +317,7 @@ private static void serverHotCertificateReload(TestHelper helper, string certifi
}
}

serverState.reloadCertificate(Path.Combine(certificatesPath, "ca2/server.p12"));
serverState.reloadCertificate(Path.Combine(certificatesPath, "ca2", "server.p12"));
{
// CA2 is accepted with the new configuration
var clientOptions = new SslClientAuthenticationOptions
Expand Down
4 changes: 4 additions & 0 deletions csharp/test/IceSSL/configuration/msbuild/client/client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
<ItemGroup>
<ProjectReference Include="../../../../../src/Ice/Ice.csproj" />
</ItemGroup>
<!-- Required for X509CertificateLoader with .NET 8-->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Bcl.Cryptography" Version="9.0.*" />
</ItemGroup>
</Project>
Loading