Skip to content

Commit

Permalink
Merge pull request #144 from Amila999/To-.NET-8
Browse files Browse the repository at this point in the history
.NET 8 and RSA
  • Loading branch information
nauful authored Feb 20, 2024
2 parents dddad72 + 18e9c36 commit 3dd9afb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NET Core/LibUA/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public virtual X509Certificate2 ApplicationCertificate
get { return null; }
}

public virtual RSACng ApplicationPrivateKey
public virtual RSA ApplicationPrivateKey
{
get { return null; }
}
Expand Down
10 changes: 6 additions & 4 deletions NET Core/TestClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ internal class Program
private class DemoClient : Client
{
private X509Certificate2 appCertificate = null;
private RSACng cryptPrivateKey = null;
private RSA cryptPrivateKey = null;

public override X509Certificate2 ApplicationCertificate
{
get { return appCertificate; }
}

public override RSACng ApplicationPrivateKey
public override RSA ApplicationPrivateKey
{
get { return cryptPrivateKey; }
}
Expand All @@ -34,7 +34,8 @@ private void LoadCertificateAndPrivateKey()
{
// Try to load existing (public key) and associated private key
appCertificate = new X509Certificate2("ClientCert.der");
cryptPrivateKey = new RSACng();
cryptPrivateKey = RSA.Create();
cryptPrivateKey.KeySize = 2048;

var rsaPrivParams = UASecurity.ImportRSAPrivateKey(File.ReadAllText("ClientKey.pem"));
cryptPrivateKey.ImportParameters(rsaPrivParams);
Expand Down Expand Up @@ -81,7 +82,8 @@ private void LoadCertificateAndPrivateKey()
File.WriteAllText("ClientCert.der", UASecurity.ExportPEM(appCertificate));
File.WriteAllText("ClientKey.pem", UASecurity.ExportRSAPrivateKey(certPrivateParams));

cryptPrivateKey = new RSACng();
cryptPrivateKey = RSA.Create();
cryptPrivateKey.KeySize = 2048;
cryptPrivateKey.ImportParameters(certPrivateParams);
}
}
Expand Down
2 changes: 1 addition & 1 deletion NET Core/TestClient/TestClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions NET Core/TestServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ private void LoadCertificateAndPrivateKey()
{
// Try to load existing (public key) and associated private key
appCertificate = new X509Certificate2("ServerCert.der");
cryptPrivateKey = new RSACng();
cryptPrivateKey = RSA.Create();
cryptPrivateKey.KeySize = 2048;

var rsaPrivParams = UASecurity.ImportRSAPrivateKey(File.ReadAllText("ServerKey.pem"));
cryptPrivateKey.ImportParameters(rsaPrivParams);
Expand Down Expand Up @@ -564,7 +565,8 @@ private void LoadCertificateAndPrivateKey()
File.WriteAllText("ServerCert.der", UASecurity.ExportPEM(appCertificate));
File.WriteAllText("ServerKey.pem", UASecurity.ExportRSAPrivateKey(certPrivateParams));

cryptPrivateKey = new RSACng();
cryptPrivateKey = RSA.Create();
cryptPrivateKey.KeySize = 2048;
cryptPrivateKey.ImportParameters(certPrivateParams);
}
}
Expand Down
2 changes: 1 addition & 1 deletion NET Core/TestServer/TestServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 3dd9afb

Please sign in to comment.