.travis.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
CMakeLists.txt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
README.md | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
doc/snippets.txt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/tools/base_lib/win/CryptoHelperWindows.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/license-generator/CMakeLists.txt | 补丁 | 查看 | 原始文档 | blame | 历史 | |
windows_download_boost.bat | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
windows_travis.bat | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.travis.yml
@@ -51,32 +51,50 @@ - docker commit centos7_toconfigure centos7_configured script: - docker run --name centos7_make -v `pwd`:/root/open-license-manager centos7_configured /bin/bash -c "cd /root/open-license-manager/build && make && make install && CTEST_OUTPUT_ON_FAILURE=1 VIRT_ENV=CONTAINER make test" "cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test" - os: windows name: "Widnows server 1803 - Visual Studio 15 2017 Win64" name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MD)" env: - CACHE_NAME=boost cache: directories: - "/C/local/boost" before_script: - ./windows_travis.bat - sc stop CryptSvc - travis_wait 30 ./windows_download_boost.bat - cd "/C/Users/travis/build/open-license-manager/open-license-manager" - mkdir build - cd build && cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" -DBOOST_ROOT="C:/local/boost" -DCMAKE_INSTALL_PREFIX=../../install .. - cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" .. script: - true # - PATH="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin":$PATH # - MSBuild.exe "license++.sln" # - ctest # - cmake -T "host=x64" -DBOOST_ROOT="C:/local/boost" -DCMAKE_INSTALL_PREFIX=../../install --build .. --target RUN_TESTS - cmake --build . --target install --config Release - ctest -C Release - os: windows name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MT)" env: - CACHE_NAME=boost cache: directories: - "/C/local/boost" before_script: #- Regsvr32.exe "C:\Widnows\System32\rsaenh.dll" - travis_wait 30 ./windows_download_boost.bat - cd "/C/Users/travis/build/open-license-manager/open-license-manager" - mkdir build - cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 .. script: - cmake --build . --target install --config Release - ctest -C Release env: - CTEST_OUTPUT_ON_FAILURE=1 before_script: - mkdir build - cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install .. script: - make - make install - CTEST_OUTPUT_ON_FAILURE=1 make test - make test CMakeLists.txt
@@ -32,19 +32,21 @@ include(target_arch) target_architecture( TARGET_ARCHITECTURE ) message(STATUS "architecture detected: ${TARGET_ARCHITECTURE}") #force to patch an error in cmake if(TARGET_ARCHITECTURE STREQUAL "x86_64") SET(CMAKE_EXE_LINKER_FLAGS "/machine:X64" CACHE STRING "Linker flags" FORCE) SET(CMAKE_MODULE_LINKER_FLAGS "/machine:X64" CACHE STRING "Module Linker flags" FORCE) SET(CMAKE_SHARED_LINKER_FLAGS "/machine:X64" CACHE STRING "Shared Linker flags" FORCE) endif() SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES} #Boost > 3.15 handle the /MD flag more nicely than this if(${STATIC_RUNTIME}) string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") SET(Boost_USE_STATIC_RUNTIME ON) endif(${STATIC_RUNTIME}) #SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES} add_definitions("/D_CRT_SECURE_NO_WARNINGS") else(MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC") #use static libraries in release to make it easier to distribute it #SET(Boost_USE_STATIC_RUNTIME ${RELEASE_BUILD}) if(RELEASE_BUILD) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries else() @@ -56,24 +58,6 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) endif(MSVC) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) if(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 1) else(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) set( Boost_USE_STATIC_LIBS ON ) find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem) #set below in case of dynamic linking in debug. #set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>) add_definitions(-DBOOST_ALL_NO_LIB) #Disable Boost Microsoft magic, all dependencies are handled by cmake add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled if(NOT MSVC) #find a static version of openssl crypto library find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) @@ -82,7 +66,6 @@ else(MINGW) list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) endif(MINGW) MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ") #Zlib required when openssl version < 1.0.1f @@ -100,12 +83,40 @@ list(APPEND EXTERNAL_LIBS dl) endif(NOT MINGW) list(APPEND EXTERNAL_LIBS "-Wl,-Bdynamic") endif(NOT MSVC) endif(MSVC) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) if(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 1) else(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) set( Boost_USE_STATIC_LIBS ON ) find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem) #set below in case of dynamic linking in debug. #set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>) add_definitions(-DBOOST_ALL_NO_LIB) #Disable Boost Microsoft magic, all dependencies are handled by cmake add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled configure_file ( "src/build_properties.h.in" "${CMAKE_BINARY_DIR}/build_properties.h" ) message( STATUS "C compiler : " ${CMAKE_C_COMPILER}) message( STATUS "C compiler flags : " ${CMAKE_C_FLAGS}) message( STATUS "CXX compiler : " ${CMAKE_CXX_COMPILER}) message( STATUS "CXX compiler flags: " ${CMAKE_CXX_FLAGS}) message( STATUS "CXX compiler flags debug : " ${CMAKE_CXX_FLAGS_DEBUG}) message( STATUS "CXX compiler flags release: " ${CMAKE_CXX_FLAGS_RELEASE}) if(CMAKE_BUILD_TYPE) message( STATUS "Build type : " ${CMAKE_BUILD_TYPE}) endif(CMAKE_BUILD_TYPE) message( STATUS "Install prefix : " ${CMAKE_INSTALL_PREFIX}) #include build directory to find build_properties.h include_directories(${CMAKE_BINARY_DIR}) @@ -119,11 +130,4 @@ ENDIF(BUILD_TESTING) add_subdirectory(test) message( STATUS "C compiler: " ${CMAKE_C_COMPILER}) message( STATUS "C compiler flags: " ${CMAKE_C_FLAGS}) message( STATUS "CXX compiler: " ${CMAKE_CXX_COMPILER}) message( STATUS "CXX compiler flags: " ${CMAKE_CXX_FLAGS}) if(CMAKE_BUILD_TYPE) message( STATUS "Build type: " ${CMAKE_BUILD_TYPE}) endif(CMAKE_BUILD_TYPE) message( STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) README.md
@@ -54,7 +54,7 @@ ## on Windows (with MSVC 2015) ``` cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=../install cmake .. -G "Visual Studio 14 2015 Win64" -DBOOST_ROOT="{Folder where boost is}" -DCMAKE_INSTALL_PREFIX=../install cmake --build . --target install --config Release ``` doc/snippets.txt
New file @@ -0,0 +1,21 @@ ## windows build boost @echo off REM build and cache boost on Windows N.B. if no output for 10 minutes it's killed by travis. REM if set every command to verbose it's killed too for "too much output"... if not exist "C:/local/boost/libs" ( echo "Boost not cached, compiling it" rem wget -q https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.7z wget -q -O boost.exe https://dl.bintray.com/boostorg/release/1.71.0/binaries/boost_1_71_0-msvc-14.1-64.exe echo "Boost downloaded" rem 7z x boost_1_71_0.7z -bb1 -oC:/local | C:\Windows\System32\findstr.exe /r /c:”cpp” rem cd "C:/local/boost_1_71_0" rem C:/local/boost_1_71_0/bootstrap.bat rem C:/local/boost_1_71_0/b2.exe -j16 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=static --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system --prefix=C:/local/boost stage rem echo "Boost compiled" rem C:/local/boost_1_71_0/b2.exe -j16 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=static --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system --prefix=C:/local/boost install > a.txt 2>&1 boost.exe /SILENT /DIR=C:\local\boost echo "Boost installed" cd C:/local/boost dir ) else echo "Boost already installed" src/tools/base_lib/win/CryptoHelperWindows.cpp
@@ -5,9 +5,10 @@ * */ #include "CryptoHelperWindows.h" #include <sstream> #include <vector> #include <string> #include "CryptoHelperWindows.h" // The RSA public-key key exchange algorithm #define ENCRYPT_ALGORITHM CALG_RSA_SIGN // The high order WORD 0x0200 (decimal 512) @@ -20,20 +21,26 @@ CryptoHelperWindows::CryptoHelperWindows() { m_hCryptProv = NULL; m_hCryptKey = NULL; if (!CryptAcquireContext(&m_hCryptProv, "license++sign", MS_ENHANCED_PROV, PROV_RSA_FULL, 0)) { if (!CryptAcquireContext(&m_hCryptProv, "license_sign", NULL, PROV_RSA_FULL, 0)) { // If the key container cannot be opened, try creating a new // container by specifying a container name and setting the // CRYPT_NEWKEYSET flag. printf("Error in AcquireContext 0x%08x \n", GetLastError()); if (NTE_BAD_KEYSET == GetLastError()) { if (!CryptAcquireContext(&m_hCryptProv, "license++sign", MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { printf("Error in AcquireContext 0x%08x \n", GetLastError()); DWORD lastError = GetLastError(); printf("Error in CryptAcquireContext (1) 0x%08x \n", lastError); if (NTE_BAD_KEYSET == lastError) { if (!CryptAcquireContext(&m_hCryptProv, "license_sign", NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { printf("Warn in CryptAcquireContext: acquiring new user keyset failed 0x%08x, trying less secure mackine keyset \n", GetLastError()); //maybe access to protected storage disabled. Try with machine keys (less secure) if (!CryptAcquireContext(&m_hCryptProv, "license_sign", NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET)) { printf("Error in CryptAcquireContext (2) 0x%08x \n", GetLastError()); if (!CryptAcquireContext(&m_hCryptProv, "license_sign", NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET)) { printf("Error in CryptAcquireContext (3): acquiring new keyset(machine) failed 0x%08x \n", GetLastError()); throw logic_error(""); } } } } else { printf(" Error in AcquireContext 0x%08x \n", GetLastError()); printf(" Error in CryptAcquireContext (4) 0x%08x \n", lastError); throw logic_error(""); } } @@ -57,12 +64,12 @@ m_hCryptKey = NULL; // Call the CryptGenKey method to get a handle // to a new exportable key-pair. if (!CryptGenKey(m_hCryptProv, ENCRYPT_ALGORITHM, if (!CryptGenKey(m_hCryptProv, ENCRYPT_ALGORITHM, KEYLENGTH | CRYPT_EXPORTABLE, &m_hCryptKey)) { dwErrCode = GetLastError(); throw logic_error( string("Error generating keys ") + to_string(static_cast<long long>(dwErrCode))); string("Error generating keys ") + to_string(static_cast<long long>(dwErrCode))); } } @@ -81,8 +88,7 @@ // This call here determines the length of the key // blob. if (!CryptExportKey(m_hCryptKey, NULL, PUBLICKEYBLOB, 0, nullptr, &dwBlobLen)) { NULL, PUBLICKEYBLOB, 0, nullptr, &dwBlobLen)) { dwErrCode = GetLastError(); throw logic_error( string("Error calculating size of public key ") @@ -98,7 +104,8 @@ delete pbKeyBlob; dwErrCode = GetLastError(); throw logic_error( string("Error exporting public key ") + to_string(static_cast<long long>(dwErrCode))); string("Error exporting public key ") + to_string(static_cast<long long>(dwErrCode))); } else { ss << "\t"; for (unsigned int i = 0; i < dwBlobLen; i++) { @@ -141,8 +148,7 @@ // This call here determines the length of the key // blob. if (!CryptExportKey(m_hCryptKey, NULL, PRIVATEKEYBLOB, 0, nullptr, &dwBlobLen)) { NULL, PRIVATEKEYBLOB, 0, nullptr, &dwBlobLen)) { dwErrCode = GetLastError(); throw logic_error( string("Error calculating size of private key ") @@ -159,7 +165,8 @@ delete pbKeyBlob; dwErrCode = GetLastError(); throw logic_error( string("Error exporting private key ") + to_string(static_cast<long long>(dwErrCode))); string("Error exporting private key ") + to_string(static_cast<long long>(dwErrCode))); } else { ss << "\t"; for (unsigned int i = 0; i < dwBlobLen; i++) { @@ -212,8 +219,8 @@ //------------------------------------------------------------------- // Acquire a cryptographic provider context handle. if (!CryptImportKey(m_hCryptProv, (const BYTE *) privateKey, (DWORD) pklen, 0, 0, &hKey)) { if (!CryptImportKey(m_hCryptProv, (const BYTE*) privateKey, (DWORD) pklen, 0, 0, &hKey)) { throw logic_error( string("Error in importing the PrivateKey ") + to_string(static_cast<long long>(GetLastError()))); @@ -259,8 +266,8 @@ //------------------------------------------------------------------- // Sign the hash object. if (CryptSignHash(hHash, AT_SIGNATURE, nullptr, 0, pbSignature, &dwSigLen)) { if (CryptSignHash(hHash, AT_SIGNATURE, nullptr, 0, pbSignature, &dwSigLen)) { printf("pbSignature is the signature length. %d\n", dwSigLen); } else { throw logic_error(string("Error during CryptSignHash.")); test/license-generator/CMakeLists.txt
windows_download_boost.bat
New file @@ -0,0 +1,9 @@ @echo off REM build and cache boost on Windows N.B. if no output for 10 minutes it's killed by travis. if not exist "C:/local/boost/libs" ( echo "Boost not cached, compiling it" wget -q -O boost.exe https://dl.bintray.com/boostorg/release/1.71.0/binaries/boost_1_71_0-msvc-14.1-64.exe echo "Boost downloaded" boost.exe /SILENT /DIR=C:\local\boost echo "Boost installed" ) else echo "Boost already installed" windows_travis.bat
File was deleted