Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hrcpp 476/nupkg #144

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ The C++ client library must match the compiler version in use for the swig wrapp
To produce the .nupkg package just run the build with the *Pack* or *QuickPack* (if the project has already been built) argument.
The toolchain produces two types of assembly with or without the natives:

* if HOTROD_ARCH env var is not empty an Infinispan.HotRod.$HOTROD_ARCH.nupkg containing the natives dll is produced;
* if HOTROD_ARCH env var is empty (or undef) an Inifnispan.HotRod.nupkg containing the toolchaing to build the natives is produced.
* if HOTROD_CLIENT_ARCH env var is not empty an Infinispan.HotRod.$HOTROD_CLIENT_ARCH.nupkg containing the natives dll is produced;
* if HOTROD_CLIENT_ARCH env var is empty (or undef) an Inifnispan.HotRod.nupkg containing the toolchaing to build the natives is produced.


### Building the native wrapper
Expand All @@ -116,6 +116,15 @@ Install the Infinispan.Hotrod.nupkg and set HOTROD_PREBUILT_DIR to the C++ clien
The system must be able to find the native libraries under the swig/native_client/lib folder so add it either to the LD_LIBRARY_PATH (linux) or to the PATH (win) variable. Define a JBOSS_HOME pointing to your Infinispan server location (in Windows use the Unix file separator '/') and then run the test suite with dotnet:
dotnet test

### Using the .nupkg
Look into the nuget archive for Infinispan.HotRod packages and find the one matching your architecture and compiler version (the C++ core uses STL so your runtime and the provided .dll must match). Add the nuget package to your .NET Core project:

dotnet add package Infinispan.HotRod.VS14-Win10-x64 --version 8.3.0.Alpha1

now your application is equipped with all the Infinispan.HotRod features... have fun!

The package comes with all the natives libraries, they will be copied into the bin\<configuration>\netcoreapp2.0 directory and you must have it on the PATH (or LD_LIBRARY_PATH) when you run the application.

## Reporting Issues ##
Infinispan uses JIRA for issue management, hosted on issues.jboss.org
(https://issues.jboss.org/browse/HRCPP). You can log in using your jboss.org
Expand Down
4 changes: 2 additions & 2 deletions buildtools/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ open Fake.NuGet.Install
open Fake.DotNetCli

let cppClientVersion = "8.1.0.SNAPSHOT"
let cppClientPackageVersion = "8.2.0-Alpha2" // nuget does not support string values after.
let cppClientPackageVersion = "8.2.0-Alpha3" // nuget does not support string values after.
let swigVersion = "3.0.12"
let protobufVersion = "3.4.0" // if changing this, be sure to also update Google.Protobuf in src/Infinispan.HotRod/Infinispan.HotRod.csproj
let nunitToolsVersion = "2.6.1"
let infinispanServerVersion = "9.1.1.Final"
let infinispanServerVersion = "9.2.3.Final"

let generateDir = "../../../src/Infinispan.HotRod/generated"
let generateSwigDir = "../src/Infinispan.HotRod/generated"
Expand Down
9 changes: 9 additions & 0 deletions nupkg/build/Infinispan.HotRod.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
22 changes: 18 additions & 4 deletions src/Infinispan.HotRod/Infinispan.HotRod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageVersion>8.2.0-Alpha2</PackageVersion>
<PackageVersion Condition="'$(HOTROD_CLIENT_VERSION)' == ''">0.0.0-SNAPSHOT</PackageVersion>
<PackageVersion Condition="'$(HOTROD_CLIENT_VERSION)' != ''">$(HOTROD_CLIENT_VERSION)</PackageVersion>
<Authors>infinispan.org</Authors>
<Description>.NET core binding of C# HotRod client for connecting to infinispan</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -25,9 +26,17 @@
</Content>
</ItemGroup>

<ItemGroup>
<NativeLibs Include="../../swig/native_client/lib/**" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


<Choose>
<When Condition="'$(ARCH)' == ''">
<When Condition="'$(HOTROD_CLIENT_ARCH)' == ''">
<PropertyGroup>
<PackageId>Infinispan.HotRod</PackageId>
</PropertyGroup>
Expand All @@ -48,11 +57,16 @@
</When>
<Otherwise>
<PropertyGroup>
<PackageId>Infinispan.HotRod.$(ARCH)</PackageId>
<PackageId>Infinispan.HotRod.$(HOTROD_CLIENT_ARCH)</PackageId>
</PropertyGroup>
<ItemGroup>
<Content Include="../../swig/native_client/lib/**">
<PackagePath>runtimes/$(ARCH)/native/</PackagePath>
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="../../nupkg/build/Infinispan.HotRod.targets">
<PackagePath>build/Infinispan.HotRod.$(HOTROD_CLIENT_ARCH).targets</PackagePath>
</Content>
</ItemGroup>
</Otherwise>
Expand Down
74 changes: 64 additions & 10 deletions test/Infinispan.HotRod.Tests/SSLTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using NUnit.Framework;
using Infinispan.HotRod.Config;
using System.Runtime.InteropServices;

namespace Infinispan.HotRod.Tests.StandaloneHotrodSSLXml
{
Expand All @@ -12,57 +13,110 @@ class SSLTest
private IRemoteCache<string, string> testCache;
private IRemoteCache<string, string> scriptCache;
private IMarshaller marshaller;
private RemoteCacheManager remoteManager;

[TearDown]
public void stopRemoteManager()
{
if ( remoteManager !=null ) {
remoteManager.Stop();
}
}

[Test]
public void WriterSuccessTest()
{
ConfigureSecuredCaches("infinispan-ca.pem", "keystore_client.p12");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("infinispan-ca.pem", clientCertName);
tester.TestWriterSuccess(testCache);
}

[Test]
public void WriterPerformsReadsTest()
{
ConfigureSecuredCaches("infinispan-ca.pem", "keystore_client.p12");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("infinispan-ca.pem", clientCertName);
tester.TestWriterPerformsReads(testCache);
}

[Test]
public void WriterPerformsSupervisorOpsTest()
{
ConfigureSecuredCaches("infinispan-ca.pem", "keystore_client.p12");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("infinispan-ca.pem", clientCertName);
tester.TestWriterPerformsSupervisorOps(testCache, scriptCache, marshaller);
}

[Ignore("https://issues.jboss.org/browse/HRCPP-434")]
[Test]
public void ClientAuthFailureTest()
{
ConfigureSecuredCaches("infinispan-ca.pem", "malicious_client.p12");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("infinispan-ca.pem", clientCertName);
tester.TestWriterSuccess(testCache);
Assert.Fail("Should not get here");
}

[Test]
public void SNI1CorrectCredentialsTest()
{
ConfigureSecuredCaches("keystore_server_sni1_rsa.pem", "keystore_client.p12", "sni1");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("keystore_server_sni1_rsa.pem", clientCertName, "sni1");
tester.TestWriterSuccess(testCache);
}

[Test]
public void SNI2CorrectCredentialsTest()
{
ConfigureSecuredCaches("keystore_server_sni2_rsa.pem", "keystore_client.p12", "sni2");
string clientCertName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
} else { Assert.Fail(); return; }
ConfigureSecuredCaches("keystore_server_sni2_rsa.pem", clientCertName, "sni2");
tester.TestWriterSuccess(testCache);
}

[Test]
public void SNIUntrustedTest()
{
Assert.Throws<Infinispan.HotRod.Exceptions.TransportException>(() => ConfigureSecuredCaches("malicious.pem", "keystore_client.p12", "sni3-untrusted"));
var ex = Assert.Throws<Infinispan.HotRod.Exceptions.TransportException>(() => tester.TestWriterSuccess(testCache));
Assert.AreEqual("**** The server certificate did not validate correctly.\n",ex.Message);
string clientCertName;
string errMessage;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
clientCertName = "keystore_client.p12";
errMessage = "**** The server certificate did not validate correctly.\n";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
clientCertName = "truststore_client.pem";
errMessage = "SSL_get_peer_certificate";
} else { Assert.Fail(); return; }
var ex = Assert.Throws<Infinispan.HotRod.Exceptions.TransportException>(() => ConfigureSecuredCaches("malicious.pem", clientCertName, "sni3-untrusted"));
Assert.AreEqual(errMessage, ex.Message);
}

private void ConfigureSecuredCaches(string serverCAFile, string clientCertFile, string sni = "")
Expand All @@ -80,7 +134,7 @@ private void ConfigureSecuredCaches(string serverCAFile, string clientCertFile,
RegisterServerCAFile(sslConf, serverCAFile, sni);
RegisterClientCertificateFile(sslConf, clientCertFile);

RemoteCacheManager remoteManager = new RemoteCacheManager(conf.Build(), true);
remoteManager = new RemoteCacheManager(conf.Build(), true);

testCache = remoteManager.GetCache<string, string>();
scriptCache = remoteManager.GetCache<string, string>("___script_cache");
Expand Down
57 changes: 57 additions & 0 deletions test/resources/certificates/truststore_client.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Bag Attributes
friendlyName: client
localKeyID: 54 69 6D 65 20 31 34 38 34 37 36 32 31 35 34 31 36 35
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDMuupRTZX52zM2
1xt/3X3JhPtjtV5k4Ua+t/KFMOa0GERyJfzYFvgaKPUQWmNCkfK+oflG8IeNhoPl
+axvWckGb9Hy78M/BPyj19h96q09KpgRtPzl7QPhQUigFe7a+k6kb+unH+21bv1X
u3btN36Q/hTMHziq+EgYSuuWhDau2NQ2xgCSrJdMOox84BPaI8RqRQhL9Ob3Q5vC
ZS936NABYkBstSIMx+w9gsP6aLh+99okBa30EY9hriP8hPJ3UfIL/0ZcamCxhFOt
p3NZlI5WNz+7Gxt0Z1JtGF86fXIj65qntLDC+J2E8/6imUTA7G0KLDbgngGga2Vm
IYtckCnLAgMBAAECggEAcnJa4rBYkqAy9Qky2jvbQXgRgB+3cPVuMtdpv4MitLKM
MLODsNjGQPl8ZXPh4SjtZhvt2fZEEJ2NxlXYSzcJ5YtE9mWJ5ATJpl3XLCywQ204
LU3bwjzI2ndAPh2EtO0QYWQffAGhRLeS8CRfyyQmoK8ouSMK7qh0xP+8yxuF5h9X
1TW9wLeB3UEI0OtpaBGtOBHq06iX0BLdaszDB3cpaH3v8RCXtrtdaB2oPvMuooKf
gQFVNik7lgahMLBEXnc8BR5/LM/lxABODADU+PUvT0c8xrpi6BmOT8V5qWWsZnZC
LWTnOKSUbHz7HdTVHL1q0qMIELI7sVjL/CA4A7kRgQKBgQDxG6hfx/OYdXQaaFm5
uWexlrVNkOirwuO4Qq46rzzYnn0mSje5btBLo872sF2/5Hfkp+4PqcI+r1qM+hGe
xYl8OH1ZELXAhPVDoix9spunh7Kyaf4cxldHVh0S+aJkKuoIu8bx3UwnDjFu55zp
z8FfI7IvKziIv5cYXyG10zFtkQKBgQDZYA8Z219W9kiDc6rPuEocGATEOQ2pEu1H
1IBwjDolLAEiMQU+TfN2M/DJpsJYIIOws2aXY9bykGEC/NmlmUXp0aUrr7gvcyXQ
bVC/Tb0c//HWs5bZJx0bfM6tuaKU6t9anBSCShLk+Sr84tDX7SdP3Qtax6HQnkZ/
eMj3TSgjmwKBgQDEy4Jey2G0qwmdFFdIFGDivtQ0/3Yp2+Tq3OJA3A+Z76LOwf1B
yYUSeB3RlJqwqdaCN99DwZfeelo6f1IqeamCTslhDRaMkPlvvsr5vfL2hvgAUCst
aWaLv2nztvYpNC3Z+wqjF7G0nw0SLNIStZRsB0LE5U47r8WwCtYFBuBtQQKBgCUK
2YfuejC3h2PfMhxzqy1eanGFx24oa4byD3EedEohVZAeCmazoelisIWshTG/WLGj
4Lerq9VqBR4dOHmfxOozb5IiP6DWXntGJZx0AuYON4f+0pXutGcavZ2dJLd7ztQC
BPyu4sliLJErlas2HpzdbjHqEwkZ76mJS7XY0B5BAoGBAMiH9bMvVneJ9IOJyS0i
rosw53t9GW9m9jIKvkMyFxlyBTyrIyqOCFhnbku7wyAT8LIWqaLEWoUU1aA1Jdki
0xjnhK/3hkN1jVq66a0Oc6sOS9RY0Nobpc9sRJxbRIaunjUV/nmGqrtgQhIoOYhg
KW8xlDPBCuTaJ61PjgpFssKG
-----END PRIVATE KEY-----
Bag Attributes
friendlyName: client
localKeyID: 54 69 6D 65 20 31 34 38 34 37 36 32 31 35 34 31 36 35
subject=/C=it/ST=mi/L=milan/O=hat/OU=red/CN=clientzilla
issuer=/C=it/ST=mi/L=milan/O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