diff --git a/README.md b/README.md index 4d843e38..29d9ae5d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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\\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 diff --git a/buildtools/build.fsx b/buildtools/build.fsx index a3375f63..01b13eb2 100644 --- a/buildtools/build.fsx +++ b/buildtools/build.fsx @@ -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" diff --git a/nupkg/build/Infinispan.HotRod.targets b/nupkg/build/Infinispan.HotRod.targets new file mode 100644 index 00000000..1a148c5d --- /dev/null +++ b/nupkg/build/Infinispan.HotRod.targets @@ -0,0 +1,9 @@ + + + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + diff --git a/src/Infinispan.HotRod/Infinispan.HotRod.csproj b/src/Infinispan.HotRod/Infinispan.HotRod.csproj index 21fea1c3..5ab55535 100644 --- a/src/Infinispan.HotRod/Infinispan.HotRod.csproj +++ b/src/Infinispan.HotRod/Infinispan.HotRod.csproj @@ -2,7 +2,8 @@ netstandard2.0 - 8.2.0-Alpha2 + 0.0.0-SNAPSHOT + $(HOTROD_CLIENT_VERSION) infinispan.org .NET core binding of C# HotRod client for connecting to infinispan false @@ -25,9 +26,17 @@ + + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + - + Infinispan.HotRod @@ -48,11 +57,16 @@ - Infinispan.HotRod.$(ARCH) + Infinispan.HotRod.$(HOTROD_CLIENT_ARCH) - runtimes/$(ARCH)/native/ + build + + + + + build/Infinispan.HotRod.$(HOTROD_CLIENT_ARCH).targets diff --git a/test/Infinispan.HotRod.Tests/SSLTest.cs b/test/Infinispan.HotRod.Tests/SSLTest.cs index af102909..60eaf09c 100644 --- a/test/Infinispan.HotRod.Tests/SSLTest.cs +++ b/test/Infinispan.HotRod.Tests/SSLTest.cs @@ -1,6 +1,7 @@ using System; using NUnit.Framework; using Infinispan.HotRod.Config; +using System.Runtime.InteropServices; namespace Infinispan.HotRod.Tests.StandaloneHotrodSSLXml { @@ -12,25 +13,52 @@ class SSLTest private IRemoteCache testCache; private IRemoteCache 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); } @@ -38,7 +66,13 @@ public void WriterPerformsSupervisorOpsTest() [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"); } @@ -46,23 +80,43 @@ public void ClientAuthFailureTest() [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(() => ConfigureSecuredCaches("malicious.pem", "keystore_client.p12", "sni3-untrusted")); - var ex = Assert.Throws(() => 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(() => ConfigureSecuredCaches("malicious.pem", clientCertName, "sni3-untrusted")); + Assert.AreEqual(errMessage, ex.Message); } private void ConfigureSecuredCaches(string serverCAFile, string clientCertFile, string sni = "") @@ -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(); scriptCache = remoteManager.GetCache("___script_cache"); diff --git a/test/resources/certificates/truststore_client.pem b/test/resources/certificates/truststore_client.pem new file mode 100644 index 00000000..a2d0a466 --- /dev/null +++ b/test/resources/certificates/truststore_client.pem @@ -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: +-----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 +MLODsNjGQPl8ZXPh4SjtZhvt2fZEEJ2NxlXYSzcJ5YtE9mWJ5ATJpl3XLCyw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0Nobpc9sRJxbRIaunjUV/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=hat/OU=red/CN=clientzilla +-----BEGIN CERTIFICATE----- +MIIDVzCCAj+gAwIBAgIERNkHRjANBgkqhkiG9w0BAQsFADBcMQswCQYDVQQGEwJp +dDELMAkGA1UECBMCbWkxDjAMBgNVBAcTBW1pbGFuMQwwCgYDVQQKEwNoYXQxDDAK +BgNVBAsTA3JlZDEUMBIGA1UEAxMLY2xpZW50emlsbGEwHhcNMTcwMTE4MTczMjQz +WhcNMTcwNDE4MTczMjQzWjBcMQswCQYDVQQGEwJpdDELMAkGA1UECBMCbWkxDjAM +BgNVBAcTBW1pbGFuMQwwCgYDVQQKEwNoYXQxDDAKBgNVBAsTA3JlZDEUMBIGA1UE +AxMLY2xpZW50emlsbGEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDM +uupRTZX52zM21xt/3X3JhPtjtV5k4Ua+t/KFMOa0GERyJfzYFvgaKPUQWmNCkfK+ +oflG8IeNhoPl+axvWckGb9Hy78M/BPyj19h96q09KpgRtPzl7QPhQUigFe7a+k6k +b+unH+21bv1Xu3btN36Q/hTMHziq+EgYSuuWhDau2NQ2xgCSrJdMOox84BPaI8Rq +RQhL9Ob3Q5vCZS936NABYkBstSIMx+w9gsP6aLh+99okBa30EY9hriP8hPJ3UfIL +/0ZcamCxhFOtp3NZlI5WNz+7Gxt0Z1JtGF86fXIj65qntLDC+J2E8/6imUTA7G0K +LDbgngGga2VmIYtckCnLAgMBAAGjITAfMB0GA1UdDgQWBBTOFmnZVt304ZpmU2Ny +eTpalYJLZDANBgkqhkiG9w0BAQsFAAOCAQEAVquQQWQpjz4ISWdMkdHHi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