This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 904c27c GEODE-4339: FIx openssl C++ example issues (#456)
904c27c is described below
commit 904c27c0c0ede2263d5b005ff1a113e1b9f9739f
Author: Blake Bender <[email protected]>
AuthorDate: Thu Mar 7 15:13:11 2019 -0800
GEODE-4339: FIx openssl C++ example issues (#456)
* Remove openssl build dependency
* Fix cpp-authinitialize example to work with C++11
* Rename cpp examples and fix cpp script permissions
* Rename dotnet put get remove example
* names now agree between c++ and .net
* Path to ssl keys provided as argument
* Disable logging
* Fix up hardcoded item in CMakeLists.txt.in
* Set script permissions properly when configuring examples
* Only copy correct scripts for the platform
* Fix up some README issues in examples
Co-authored-by: Ivan Godwin <[email protected]>
Co-authored-by: Matthew Reddington <[email protected]>
Co-authored-by: Mike Martell <[email protected]>
---
examples/BUILD-EXAMPLES.md | 10 ++---
examples/CMakeLists.txt | 1 -
examples/CMakeLists.txt.in | 1 -
examples/cpp/CMakeLists.txt | 5 ++-
examples/cpp/CMakeLists.txt.cpp_example.in | 19 ++++++--
examples/cpp/CMakeLists.txt.in | 8 ++--
examples/cpp/authinitialize/main.cpp | 16 +++----
.../README.md | 0
.../main.cpp | 0
.../startserver.ps1 | 0
.../startserver.sh | 0
.../stopserver.ps1 | 0
.../stopserver.sh | 0
.../cpp/{put-get-remove => putgetremove}/README.md | 0
.../cpp/{put-get-remove => putgetremove}/main.cpp | 0
.../putgetremove}/startserver.ps1 | 0
.../startserver.sh | 0
.../putgetremove}/stopserver.ps1 | 0
.../{put-get-remove => putgetremove}/stopserver.sh | 0
examples/cpp/sslputget/CMakeLists.txt.in | 27 +++++++-----
examples/cpp/sslputget/README.md | 2 +-
examples/cpp/sslputget/main.cpp | 50 ++++++++--------------
examples/dotnet/CMakeLists.txt | 2 +-
examples/dotnet/CMakeLists.txt.in | 6 +--
.../{put-get-remove => putgetremove}/Program.cs | 0
.../{put-get-remove => putgetremove}/README.md | 0
.../putgetremove}/startserver.ps1 | 0
.../putgetremove}/stopserver.ps1 | 0
examples/dotnet/sslputget/CMakeLists.txt.in | 4 --
examples/dotnet/sslputget/README.md | 2 +-
30 files changed, 75 insertions(+), 78 deletions(-)
diff --git a/examples/BUILD-EXAMPLES.md b/examples/BUILD-EXAMPLES.md
index dfae507..9455b3a 100644
--- a/examples/BUILD-EXAMPLES.md
+++ b/examples/BUILD-EXAMPLES.md
@@ -6,7 +6,7 @@
* Build and install [Apache Geode
Native](https://github.com/apache/geode-native)
* Set `GEODE_HOME` to the install directory of Apache Geode
* **For Windows:** Visual Studio 2017
-* Optional: OpenSSL (to build and run the SSL examples)
+* Optional: OpenSSL (to run the SSL examples)
## Building the Examples
@@ -20,18 +20,18 @@
$ cd workspace/examples
$ mkdir build
$ cd build
- $ cmake .. -DGEODE_ROOT="<geode-install-dir>"
+ $ cmake .. -DGeodeNative_ROOT="<geode-native-install-dir>"
$ cmake --build . -- <optional parallelism parameter>
```
where the optional parallelism parameter is of the form `-j n`.
**For Windows:** Include options that specify the generator, the
architecture toolset, and the path to the Geode Native installation:
- $ cd workspace/examples/
+ $ cd workspace\examples\
$ mkdir build
$ cd build
- $ cmake <geode-native-install-dir>/examples -G"Visual Studio 15 2017
Win64"
- $ cmake --build .
+ $ cmake .. -G"Visual Studio 15 2017 Win64"
-DGeodeNative_ROOT="<geode-native-install-dir>"
+ $ cmake --build . -- <optional parallelism parameter>
## Running the Examples
To run an example,
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index b5099ab..1172a39 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -48,7 +48,6 @@ if (BUILD_CLI)
PATTERN "*.in" EXCLUDE)
add_subdirectory(dotnet)
- find_package(OpenSSL)
endif()
add_subdirectory(utilities)
diff --git a/examples/CMakeLists.txt.in b/examples/CMakeLists.txt.in
index 8705564..89211bf 100644
--- a/examples/CMakeLists.txt.in
+++ b/examples/CMakeLists.txt.in
@@ -17,7 +17,6 @@ cmake_minimum_required(VERSION 3.10)
project(examples LANGUAGES NONE)
-find_package(OpenSSL)
add_subdirectory(cpp)
@DOTNET_SUB_DIRECTORY@
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 13fc1a6..36f04e0 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -39,7 +39,7 @@ add_example(NAME continuousquery
add_example(NAME dataserializable
SOURCE main.cpp Order.cpp Order.hpp)
-add_example(NAME function-execution
+add_example(NAME functionexecution
SOURCE main.cpp)
add_example(NAME pdxserializable
@@ -48,7 +48,7 @@ add_example(NAME pdxserializable
add_example(NAME pdxserializer
SOURCE main.cpp Order.cpp Order.hpp OrderSerializer.cpp
OrderSerializer.hpp)
-add_example(NAME put-get-remove
+add_example(NAME putgetremove
SOURCE main.cpp)
add_example(NAME remotequery
@@ -61,6 +61,7 @@ add_example(NAME transaction
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DESTINATION examples/
+ USE_SOURCE_PERMISSIONS
PATTERN "./*.in" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "Makefile" EXCLUDE
diff --git a/examples/cpp/CMakeLists.txt.cpp_example.in
b/examples/cpp/CMakeLists.txt.cpp_example.in
index e08c150..15a858c 100644
--- a/examples/cpp/CMakeLists.txt.cpp_example.in
+++ b/examples/cpp/CMakeLists.txt.cpp_example.in
@@ -24,10 +24,21 @@ find_package(@PRODUCT_NAME_NOSPACE@ REQUIRED COMPONENTS cpp)
add_executable(${PROJECT_NAME} @ADD_EXAMPLE_SOURCE@)
-configure_file("startserver.ps1" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("stopserver.ps1" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("startserver.sh" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("stopserver.sh" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+if(WIN32)
+set(SCRIPT_EXTENSION ps1)
+else()
+set(SCRIPT_EXTENSION sh)
+endif()
+
+file(GLOB SERVER_SCRIPTS
+ "${CMAKE_CURRENT_SOURCE_DIR}/*${SCRIPT_EXTENSION}"
+)
+
+file(INSTALL ${SERVER_SCRIPTS}
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
+)
+
configure_file("README.md" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
target_link_libraries(${PROJECT_NAME}
diff --git a/examples/cpp/CMakeLists.txt.in b/examples/cpp/CMakeLists.txt.in
index 9bae74c..8360f85 100644
--- a/examples/cpp/CMakeLists.txt.in
+++ b/examples/cpp/CMakeLists.txt.in
@@ -20,13 +20,11 @@ project(@[email protected] LANGUAGES NONE)
add_subdirectory(authinitialize)
add_subdirectory(continuousquery)
add_subdirectory(dataserializable)
-add_subdirectory(function-execution)
+add_subdirectory(functionexecution)
add_subdirectory(pdxserializable)
add_subdirectory(pdxserializer)
-add_subdirectory(put-get-remove)
+add_subdirectory(putgetremove)
add_subdirectory(remotequery)
add_subdirectory(transaction)
-if(OPENSSL_FOUND)
- add_subdirectory(sslputget)
-endif()
+add_subdirectory(sslputget)
diff --git a/examples/cpp/authinitialize/main.cpp
b/examples/cpp/authinitialize/main.cpp
index 3b27e53..324535f 100644
--- a/examples/cpp/authinitialize/main.cpp
+++ b/examples/cpp/authinitialize/main.cpp
@@ -30,16 +30,16 @@ using apache::geode::client::CacheableString;
int main(int argc, char** argv) {
auto cache = CacheFactory()
- .set("log-level", "none")
-
.setAuthInitialize(std::make_unique<ExampleAuthInitialize>())
- .create();
+ .set("log-level", "none")
+ .setAuthInitialize(std::unique_ptr<ExampleAuthInitialize>(new
ExampleAuthInitialize()))
+ .create();
auto pool = cache.getPoolManager()
- .createFactory()
- .addLocator("localhost", 10334)
- .create("pool");
+ .createFactory()
+ .addLocator("localhost", 10334)
+ .create("pool");
auto region = cache.createRegionFactory(RegionShortcut::PROXY)
- .setPoolName("pool")
- .create("region");
+ .setPoolName("pool")
+ .create("region");
region->put("a", "1");
region->put("b", "2");
diff --git a/examples/cpp/function-execution/README.md
b/examples/cpp/functionexecution/README.md
similarity index 100%
rename from examples/cpp/function-execution/README.md
rename to examples/cpp/functionexecution/README.md
diff --git a/examples/cpp/function-execution/main.cpp
b/examples/cpp/functionexecution/main.cpp
similarity index 100%
rename from examples/cpp/function-execution/main.cpp
rename to examples/cpp/functionexecution/main.cpp
diff --git a/examples/cpp/function-execution/startserver.ps1
b/examples/cpp/functionexecution/startserver.ps1
similarity index 100%
rename from examples/cpp/function-execution/startserver.ps1
rename to examples/cpp/functionexecution/startserver.ps1
diff --git a/examples/cpp/function-execution/startserver.sh
b/examples/cpp/functionexecution/startserver.sh
similarity index 100%
rename from examples/cpp/function-execution/startserver.sh
rename to examples/cpp/functionexecution/startserver.sh
diff --git a/examples/cpp/function-execution/stopserver.ps1
b/examples/cpp/functionexecution/stopserver.ps1
similarity index 100%
rename from examples/cpp/function-execution/stopserver.ps1
rename to examples/cpp/functionexecution/stopserver.ps1
diff --git a/examples/cpp/function-execution/stopserver.sh
b/examples/cpp/functionexecution/stopserver.sh
similarity index 100%
rename from examples/cpp/function-execution/stopserver.sh
rename to examples/cpp/functionexecution/stopserver.sh
diff --git a/examples/cpp/put-get-remove/README.md
b/examples/cpp/putgetremove/README.md
similarity index 100%
rename from examples/cpp/put-get-remove/README.md
rename to examples/cpp/putgetremove/README.md
diff --git a/examples/cpp/put-get-remove/main.cpp
b/examples/cpp/putgetremove/main.cpp
similarity index 100%
rename from examples/cpp/put-get-remove/main.cpp
rename to examples/cpp/putgetremove/main.cpp
diff --git a/examples/dotnet/put-get-remove/startserver.ps1
b/examples/cpp/putgetremove/startserver.ps1
similarity index 100%
rename from examples/dotnet/put-get-remove/startserver.ps1
rename to examples/cpp/putgetremove/startserver.ps1
diff --git a/examples/cpp/put-get-remove/startserver.sh
b/examples/cpp/putgetremove/startserver.sh
similarity index 100%
rename from examples/cpp/put-get-remove/startserver.sh
rename to examples/cpp/putgetremove/startserver.sh
diff --git a/examples/dotnet/put-get-remove/stopserver.ps1
b/examples/cpp/putgetremove/stopserver.ps1
similarity index 100%
rename from examples/dotnet/put-get-remove/stopserver.ps1
rename to examples/cpp/putgetremove/stopserver.ps1
diff --git a/examples/cpp/put-get-remove/stopserver.sh
b/examples/cpp/putgetremove/stopserver.sh
similarity index 100%
rename from examples/cpp/put-get-remove/stopserver.sh
rename to examples/cpp/putgetremove/stopserver.sh
diff --git a/examples/cpp/sslputget/CMakeLists.txt.in
b/examples/cpp/sslputget/CMakeLists.txt.in
index e6a8665..dd2d44d 100644
--- a/examples/cpp/sslputget/CMakeLists.txt.in
+++ b/examples/cpp/sslputget/CMakeLists.txt.in
@@ -20,15 +20,25 @@ project(cpp-sslputget LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
set(CMAKE_CXX_STANDARD 11)
-find_package(GeodeNative REQUIRED COMPONENTS cpp crypto)
-find_package(OpenSSL REQUIRED COMPONENTS SSL)
+find_package(@PRODUCT_NAME_NOSPACE@ REQUIRED COMPONENTS cpp crypto)
add_executable(${PROJECT_NAME} main.cpp)
-configure_file("startserver.sh" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("stopserver.sh" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("startserver.ps1" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-configure_file("stopserver.ps1" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+if(WIN32)
+set(SCRIPT_EXTENSION ps1)
+else()
+set(SCRIPT_EXTENSION sh)
+endif()
+
+file(GLOB SERVER_SCRIPTS
+ "${CMAKE_CURRENT_SOURCE_DIR}/*${SCRIPT_EXTENSION}"
+)
+
+file(INSTALL ${SERVER_SCRIPTS}
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
+)
+
configure_file("README.md" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
file(GLOB SSL_CERTIFICATES
@@ -42,9 +52,6 @@ target_link_libraries(${PROJECT_NAME}
@PRODUCT_NAME_NOSPACE@::cpp)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- $<SHELL_PATH:$<TARGET_FILE_DIR:OpenSSL::SSL>/../bin>
- $<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
COMMAND ${CMAKE_COMMAND} -E copy
$<SHELL_PATH:$<TARGET_FILE:GeodeNative::crypto>>
$<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
@@ -53,7 +60,7 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
-
$<SHELL_PATH:$<TARGET_FILE_DIR:GeodeNative::cpp>/../bin/@[email protected]>
+
$<SHELL_PATH:$<TARGET_FILE_DIR:@PRODUCT_NAME_NOSPACE@::cpp>/../bin/@[email protected]>
$<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
)
endif()
diff --git a/examples/cpp/sslputget/README.md b/examples/cpp/sslputget/README.md
index f7b417d..3aff841 100644
--- a/examples/cpp/sslputget/README.md
+++ b/examples/cpp/sslputget/README.md
@@ -6,7 +6,7 @@ This example illustrates how to use SSL encryption for all
traffic between a cli
* Build and install [Apache Geode
Native](https://github.com/apache/geode-native)
* Apache Geode Native examples, built and installed
* Set `GEODE_HOME` to the install directory of Apache Geode
-* Install [OpenSSL]()
+* Install [OpenSSL](https://www.openssl.org/)
## Running
1. From a command shell, set the current directory to the `sslputget`
directory in your example workspace.
diff --git a/examples/cpp/sslputget/main.cpp b/examples/cpp/sslputget/main.cpp
index 9bee39c..2de9462 100644
--- a/examples/cpp/sslputget/main.cpp
+++ b/examples/cpp/sslputget/main.cpp
@@ -14,15 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifdef _MSC_VER
-#include <direct.h>
-#include <stdlib.h>
-#include <windows.h>
-#undef max
-#else
-#include <unistd.h>
-#endif
-
#include <iostream>
#include <memory>
#include <string>
@@ -37,40 +28,37 @@ using apache::geode::client::CacheableString;
using apache::geode::client::CacheFactory;
using apache::geode::client::RegionShortcut;
-std::string myGetcwd() {
- std::string cwd;
-
-#ifdef _MSC_VER
- char buf[MAX_PATH];
-
- if (_getcwd(buf, MAX_PATH)) {
- cwd = buf;
- }
-#else
- char buf[PATH_MAX];
- if (getcwd(buf, PATH_MAX)) {
- cwd = buf;
- }
-#endif
- return cwd;
+void print_usage() {
+ printf("Usage: cpp-sslputget <<path>>\n");
+ printf("Where <<path>> is the absolute path to the location of your SSL "
+ "client keystore and truststore\n");
}
int main(int argc, char** argv) {
- auto workingDirectory = myGetcwd();
+ if (argc < 2) {
+ print_usage();
+ exit(-1);
+ }
-#ifdef _MSC_VER
- workingDirectory += "/..";
-#endif
+ auto sslKeyPath = std::string(argv[1]);
auto cache =
CacheFactory()
.set("log-level", "none")
.set("ssl-enabled", "true")
.set("ssl-keystore",
- workingDirectory +
"/ClientSslKeys/client_keystore.password.pem")
+#ifdef WIN32
+ (sslKeyPath + "\\client_keystore.password.pem").c_str())
+#else
+ (sslKeyPath + "/client_keystore.password.pem").c_str())
+#endif
.set("ssl-keystore-password", "gemstone")
.set("ssl-truststore",
- workingDirectory + "/ClientSslKeys/client_truststore.pem")
+#ifdef WIN32
+ (sslKeyPath + "\\client_truststore.pem").c_str())
+#else
+ (sslKeyPath + "/client_truststore.pem").c_str())
+#endif
.create();
const auto pool = cache.getPoolManager()
diff --git a/examples/dotnet/CMakeLists.txt b/examples/dotnet/CMakeLists.txt
index 0c05a97..fba2374 100644
--- a/examples/dotnet/CMakeLists.txt
+++ b/examples/dotnet/CMakeLists.txt
@@ -64,7 +64,7 @@ add_example(NAME pdxautoserializer
add_example(NAME pdxserializable
SOURCE Order.cs Program.cs)
-add_example(NAME put-get-remove
+add_example(NAME putgetremove
SOURCE Program.cs)
add_example(NAME remotequery
diff --git a/examples/dotnet/CMakeLists.txt.in
b/examples/dotnet/CMakeLists.txt.in
index 9d8c962..19935c2 100644
--- a/examples/dotnet/CMakeLists.txt.in
+++ b/examples/dotnet/CMakeLists.txt.in
@@ -23,10 +23,8 @@ add_subdirectory(dataserializable)
add_subdirectory(functionexecution)
add_subdirectory(pdxautoserializer)
add_subdirectory(pdxserializable)
-add_subdirectory(put-get-remove)
+add_subdirectory(putgetremove)
add_subdirectory(remotequery)
add_subdirectory(transaction)
-if(OPENSSL_FOUND)
- add_subdirectory(sslputget)
-endif()
+add_subdirectory(sslputget)
diff --git a/examples/dotnet/put-get-remove/Program.cs
b/examples/dotnet/putgetremove/Program.cs
similarity index 100%
rename from examples/dotnet/put-get-remove/Program.cs
rename to examples/dotnet/putgetremove/Program.cs
diff --git a/examples/dotnet/put-get-remove/README.md
b/examples/dotnet/putgetremove/README.md
similarity index 100%
rename from examples/dotnet/put-get-remove/README.md
rename to examples/dotnet/putgetremove/README.md
diff --git a/examples/cpp/put-get-remove/startserver.ps1
b/examples/dotnet/putgetremove/startserver.ps1
similarity index 100%
rename from examples/cpp/put-get-remove/startserver.ps1
rename to examples/dotnet/putgetremove/startserver.ps1
diff --git a/examples/cpp/put-get-remove/stopserver.ps1
b/examples/dotnet/putgetremove/stopserver.ps1
similarity index 100%
rename from examples/cpp/put-get-remove/stopserver.ps1
rename to examples/dotnet/putgetremove/stopserver.ps1
diff --git a/examples/dotnet/sslputget/CMakeLists.txt.in
b/examples/dotnet/sslputget/CMakeLists.txt.in
index df64a97..7152046 100644
--- a/examples/dotnet/sslputget/CMakeLists.txt.in
+++ b/examples/dotnet/sslputget/CMakeLists.txt.in
@@ -20,7 +20,6 @@ project(dotnet-sslputget LANGUAGES CSharp)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
find_package(GeodeNative REQUIRED COMPONENTS dotnet crypto)
-find_package(OpenSSL REQUIRED COMPONENTS SSL)
add_executable(${PROJECT_NAME} Program.cs)
@@ -43,9 +42,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- $<SHELL_PATH:$<TARGET_FILE_DIR:OpenSSL::SSL>/../bin>
- $<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
COMMAND ${CMAKE_COMMAND} -E copy
$<SHELL_PATH:$<TARGET_FILE:GeodeNative::crypto>>
$<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
diff --git a/examples/dotnet/sslputget/README.md
b/examples/dotnet/sslputget/README.md
index a70b334..4982a9b 100644
--- a/examples/dotnet/sslputget/README.md
+++ b/examples/dotnet/sslputget/README.md
@@ -4,7 +4,7 @@ This example illustrates how to use SSL encryption for all
traffic between a .NE
## Prerequisites
* Install [Apache Geode](https://geode.apache.org)
* Build and install [Apache Geode
Native](https://github.com/apache/geode-native)
-* Install [OpenSSL]()
+* Install [OpenSSL](https://www.openssl.org/)
## Running
* Run the following Powershell script which starts the Geode Locator, defines
the keystore and truststore certificates, starts the Geode Server, and creates
the region.