changeset 26:6ba765ecf3db

compiling openssl
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Aug 2012 15:10:02 +0200
parents dd1489098265
children cfe212a513c5
files CMakeLists.txt PalantirCppClient/HttpClient.cpp PalantirServer/main.cpp Resources/CMake/LibCurlConfiguration.cmake Resources/CMake/MongooseConfiguration.cmake Resources/CMake/OpenSslConfiguration.cmake UnitTests/main.cpp
diffstat 7 files changed, 171 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Aug 28 11:20:49 2012 +0200
+++ b/CMakeLists.txt	Tue Aug 28 15:10:02 2012 +0200
@@ -28,6 +28,7 @@
   ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
   ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
   )
+
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
@@ -38,9 +39,15 @@
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
 
+if (${ENABLE_SSL})
+  include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
+endif()
+
 
 if (${CMAKE_COMPILER_IS_GNUCXX})
-  set(CMAKE_C_FLAGS "-Wall -pedantic -Wno-implicit-function-declaration")  # --std=c99 makes libcurl not to compile
+  set(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-implicit-function-declaration")  
+  # --std=c99 makes libcurl not to compile
+  # -pedantic gives a lot of warnings on OpenSSL 
   set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wno-long-long -Wno-variadic-macros")
 elseif (${MSVC})
   # http://stackoverflow.com/a/6510446
@@ -184,7 +191,6 @@
 TARGET_LINK_LIBRARIES(Palantir ServerLibrary CoreLibrary)
 TARGET_LINK_LIBRARIES(UnitTests ServerLibrary CoreLibrary)
 
-
 find_package(Doxygen)
 if (DOXYGEN_FOUND)
   configure_file(
--- a/PalantirCppClient/HttpClient.cpp	Tue Aug 28 11:20:49 2012 +0200
+++ b/PalantirCppClient/HttpClient.cpp	Tue Aug 28 15:10:02 2012 +0200
@@ -87,6 +87,10 @@
     CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_HEADER, 0));
     CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_FOLLOWLOCATION, 1));
 
+#if PALANTIR_SSL_ENABLED == 1
+    CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_SSL_VERIFYPEER, 0)); 
+#endif
+
     url_ = "";
     method_ = HttpMethod_Get;
     lastStatus_ = HttpStatus_200_Ok;
--- a/PalantirServer/main.cpp	Tue Aug 28 11:20:49 2012 +0200
+++ b/PalantirServer/main.cpp	Tue Aug 28 15:10:02 2012 +0200
@@ -95,18 +95,17 @@
 
 int main(int argc, char* argv[]) 
 {
-  if (argc >= 2)
-  {
-    PalantirInitialize(argv[1]);
-  }
-  else
-  {
-    PalantirInitialize();
-  }
-
-
   try
   {
+    if (argc >= 2)
+    {
+      PalantirInitialize(argv[1]);
+    }
+    else
+    {
+      PalantirInitialize();
+    }
+
     std::string storageDirectory = GetGlobalStringParameter("StorageDirectory", "PalantirStorage");
     ServerIndex index(storageDirectory);
     MyDicomStoreFactory storeScp(index, storageDirectory);
@@ -157,13 +156,13 @@
     }
 
     storeScp.Done();
+
+    PalantirFinalize();
   }
   catch (PalantirException& e)
   {
     std::cout << "EXCEPT [" << e.What() << "]" << std::endl;
   }
 
-  PalantirFinalize();
-
   return 0;
 }
--- a/Resources/CMake/LibCurlConfiguration.cmake	Tue Aug 28 11:20:49 2012 +0200
+++ b/Resources/CMake/LibCurlConfiguration.cmake	Tue Aug 28 15:10:02 2012 +0200
@@ -4,7 +4,7 @@
 
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
-      SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/x86_64-linux)
+      SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/WithSsl/x86_64-linux)
     elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
       SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i686-pc-linux-gnu)
     else()
--- a/Resources/CMake/MongooseConfiguration.cmake	Tue Aug 28 11:20:49 2012 +0200
+++ b/Resources/CMake/MongooseConfiguration.cmake	Tue Aug 28 15:10:02 2012 +0200
@@ -15,9 +15,11 @@
   ${MONGOOSE_SOURCES_DIR}/mongoose.c
   )
 
+
 if (${ENABLE_SSL})
   add_definitions(
     -DPALANTIR_SSL_ENABLED=1
+    -DNO_SSL_DL=1
     )
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     link_libraries(dl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/OpenSslConfiguration.cmake	Tue Aug 28 15:10:02 2012 +0200
@@ -0,0 +1,137 @@
+if (${STATIC_BUILD})
+  SET(OPENSSL_SOURCES_DIR ${CMAKE_BINARY_DIR}/openssl-1.0.1c)
+  DownloadPackage("http://www.openssl.org/source/openssl-1.0.1c.tar.gz" "${OPENSSL_SOURCES_DIR}" "" "")
+
+  add_definitions(
+    -DOPENSSL_THREADS
+    -DOPENSSL_IA32_SSE2
+    -DOPENSSL_NO_ASM
+    -DOPENSSL_NO_DYNAMIC_ENGINE
+    -DNO_WINDOWS_BRAINDEATH
+
+    -DOPENSSL_NO_BF 
+    -DOPENSSL_NO_CAMELLIA
+    -DOPENSSL_NO_CAST 
+    -DOPENSSL_NO_EC
+    -DOPENSSL_NO_ECDH
+    -DOPENSSL_NO_ECDSA
+    -DOPENSSL_NO_EC_NISTP_64_GCC_128
+    -DOPENSSL_NO_GMP
+    -DOPENSSL_NO_GOST
+    -DOPENSSL_NO_HW
+    -DOPENSSL_NO_JPAKE
+    -DOPENSSL_NO_IDEA
+    -DOPENSSL_NO_KRB5 
+    -DOPENSSL_NO_MD2 
+    -DOPENSSL_NO_MDC2 
+    -DOPENSSL_NO_MD4
+    -DOPENSSL_NO_RC2 
+    -DOPENSSL_NO_RC4 
+    -DOPENSSL_NO_RC5 
+    -DOPENSSL_NO_RFC3779
+    -DOPENSSL_NO_SCTP
+    -DOPENSSL_NO_STORE
+    -DOPENSSL_NO_SEED
+    -DOPENSSL_NO_WHIRLPOOL
+    -DOPENSSL_NO_RIPEMD
+    )
+
+  include_directories(
+    ${OPENSSL_SOURCES_DIR}
+    ${OPENSSL_SOURCES_DIR}/crypto
+    ${OPENSSL_SOURCES_DIR}/crypto/asn1
+    ${OPENSSL_SOURCES_DIR}/crypto/modes
+    ${OPENSSL_SOURCES_DIR}/crypto/evp
+    ${OPENSSL_SOURCES_DIR}/include
+    )
+
+  set(OPENSSL_SOURCES_SUBDIRS
+    ${OPENSSL_SOURCES_DIR}/crypto
+    ${OPENSSL_SOURCES_DIR}/crypto/aes
+    ${OPENSSL_SOURCES_DIR}/crypto/asn1
+    ${OPENSSL_SOURCES_DIR}/crypto/bio
+    ${OPENSSL_SOURCES_DIR}/crypto/bn
+    ${OPENSSL_SOURCES_DIR}/crypto/buffer
+    ${OPENSSL_SOURCES_DIR}/crypto/cmac
+    ${OPENSSL_SOURCES_DIR}/crypto/cms
+    ${OPENSSL_SOURCES_DIR}/crypto/comp
+    ${OPENSSL_SOURCES_DIR}/crypto/conf
+    ${OPENSSL_SOURCES_DIR}/crypto/des
+    ${OPENSSL_SOURCES_DIR}/crypto/dh
+    ${OPENSSL_SOURCES_DIR}/crypto/dsa
+    ${OPENSSL_SOURCES_DIR}/crypto/dso
+    ${OPENSSL_SOURCES_DIR}/crypto/engine
+    ${OPENSSL_SOURCES_DIR}/crypto/err
+    ${OPENSSL_SOURCES_DIR}/crypto/evp
+    ${OPENSSL_SOURCES_DIR}/crypto/hmac
+    ${OPENSSL_SOURCES_DIR}/crypto/lhash
+    ${OPENSSL_SOURCES_DIR}/crypto/md5
+    ${OPENSSL_SOURCES_DIR}/crypto/modes
+    ${OPENSSL_SOURCES_DIR}/crypto/objects
+    ${OPENSSL_SOURCES_DIR}/crypto/ocsp
+    ${OPENSSL_SOURCES_DIR}/crypto/pem
+    ${OPENSSL_SOURCES_DIR}/crypto/pkcs12
+    ${OPENSSL_SOURCES_DIR}/crypto/pkcs7
+    ${OPENSSL_SOURCES_DIR}/crypto/pqueue
+    ${OPENSSL_SOURCES_DIR}/crypto/rand
+    ${OPENSSL_SOURCES_DIR}/crypto/rsa
+    ${OPENSSL_SOURCES_DIR}/crypto/sha
+    ${OPENSSL_SOURCES_DIR}/crypto/srp
+    ${OPENSSL_SOURCES_DIR}/crypto/stack
+    ${OPENSSL_SOURCES_DIR}/crypto/ts
+    ${OPENSSL_SOURCES_DIR}/crypto/txt_db
+    ${OPENSSL_SOURCES_DIR}/crypto/ui
+    ${OPENSSL_SOURCES_DIR}/crypto/x509
+    ${OPENSSL_SOURCES_DIR}/crypto/x509v3
+    ${OPENSSL_SOURCES_DIR}/ssl
+    )
+
+  foreach(d ${OPENSSL_SOURCES_SUBDIRS})
+    AUX_SOURCE_DIRECTORY(${d} OPENSSL_SOURCES)
+  endforeach()
+
+  list(REMOVE_ITEM OPENSSL_SOURCES
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_nyi.c
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_unix.c
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_vms.c
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win.c
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win32.c
+    ${OPENSSL_SOURCES_DIR}/crypto/LPdir_wince.c
+    ${OPENSSL_SOURCES_DIR}/crypto/armcap.c
+    ${OPENSSL_SOURCES_DIR}/crypto/bf/bfs.cpp
+    ${OPENSSL_SOURCES_DIR}/crypto/bio/bss_rtcp.c
+    ${OPENSSL_SOURCES_DIR}/crypto/bn/exp.c
+    ${OPENSSL_SOURCES_DIR}/crypto/conf/cnf_save.c
+    ${OPENSSL_SOURCES_DIR}/crypto/conf/test.c
+    ${OPENSSL_SOURCES_DIR}/crypto/des/des3s.cpp
+    ${OPENSSL_SOURCES_DIR}/crypto/des/des_opts.c
+    ${OPENSSL_SOURCES_DIR}/crypto/des/dess.cpp
+    ${OPENSSL_SOURCES_DIR}/crypto/des/read_pwd.c
+    ${OPENSSL_SOURCES_DIR}/crypto/des/speed.c
+    ${OPENSSL_SOURCES_DIR}/crypto/evp/e_dsa.c
+    ${OPENSSL_SOURCES_DIR}/crypto/evp/m_ripemd.c
+    ${OPENSSL_SOURCES_DIR}/crypto/lhash/lh_test.c
+    ${OPENSSL_SOURCES_DIR}/crypto/md5/md5s.cpp
+    ${OPENSSL_SOURCES_DIR}/crypto/pkcs7/bio_ber.c
+    ${OPENSSL_SOURCES_DIR}/crypto/pkcs7/pk7_enc.c
+    ${OPENSSL_SOURCES_DIR}/crypto/ppccap.c
+    ${OPENSSL_SOURCES_DIR}/crypto/s390xcap.c
+    ${OPENSSL_SOURCES_DIR}/crypto/sparcv9cap.c
+    ${OPENSSL_SOURCES_DIR}/crypto/x509v3/tabtest.c
+    ${OPENSSL_SOURCES_DIR}/crypto/x509v3/v3conf.c
+    ${OPENSSL_SOURCES_DIR}/ssl/ssl_task.c
+    )
+
+  add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
+  link_libraries(OpenSSL)
+
+else()
+  include(FindOpenSSL)
+
+  if (NOT ${OPENSSL_FOUND})
+    message(FATAL_ERROR "Unable to find OpenSSL")
+  endif()
+
+  include_directories(${OPENSSL_INCLUDE_DIR})
+  link_libraries(${OPENSSL_LIBRARIES})
+endif()
--- a/UnitTests/main.cpp	Tue Aug 28 11:20:49 2012 +0200
+++ b/UnitTests/main.cpp	Tue Aug 28 15:10:02 2012 +0200
@@ -273,6 +273,14 @@
   ASSERT_EQ("SGVsbG8gd29ybGQ=", Toolbox::EncodeBase64("Hello world"));
 }
 
+TEST(tutu, tata)
+{
+  HttpClient c;
+  c.SetUrl("https://localhost:8000/instances");
+  std::string s;
+  ASSERT_TRUE(c.Apply(s));
+}
+
 
 int main(int argc, char **argv)
 {