diff --git a/CMakeLists.txt b/CMakeLists.txt index ce16d53..df3283d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ endif(WITH_FONTCONFIGURATION_FONTCONFIG) macro_optional_find_package(JPEG) macro_optional_find_package(PNG) macro_optional_find_package(TIFF) -find_package(NSS3 REQUIRED) +macro_optional_find_package(NSS3) if(JPEG_FOUND) set(ENABLE_LIBJPEG ${JPEG_FOUND}) endif(JPEG_FOUND) @@ -203,8 +203,6 @@ if(ENABLE_LIBCURL) set(POPPLER_HAS_CURL_SUPPORT ON) endif(ENABLE_LIBCURL) -add_definitions(${NSS3_CFLAGS}) - add_definitions(-DHAVE_CONFIG_H=1) if(MINGW) # Use mingw's ansi stdio extensions @@ -237,6 +235,11 @@ endif(CMAKE_USE_PTHREADS_INIT) if(ENABLE_ZLIB) include_directories(${ZLIB_INCLUDE_DIR}) endif(ENABLE_ZLIB) + +if (NSS3_FOUND) + add_definitions(${NSS3_CFLAGS}) + set(ENABLE_NSS3 ON) +endif(NSS3_FOUND) if(JPEG_FOUND) include_directories(${JPEG_INCLUDE_DIR}) set(ENABLE_LIBJPEG ON) @@ -367,8 +370,6 @@ set(poppler_SRCS poppler/ProfileData.cc poppler/PreScanOutputDev.cc poppler/PSTokenizer.cc - poppler/SignatureHandler.cc - poppler/SignatureInfo.cc poppler/Stream.cc poppler/StructTreeRoot.cc poppler/StructElement.cc @@ -417,7 +418,7 @@ endif(ENABLE_SPLASH) if(FONTCONFIG_FOUND) set(poppler_LIBS ${poppler_LIBS} ${FONTCONFIG_LIBRARIES}) endif(FONTCONFIG_FOUND) -set(poppler_LIBS ${poppler_LIBS} ${NSS3_LIBRARIES}) + if(JPEG_FOUND) set(poppler_SRCS ${poppler_SRCS} poppler/DCTStream.cc @@ -437,6 +438,13 @@ if(ENABLE_LIBCURL) ) set(poppler_LIBS ${poppler_LIBS} ${CURL_LIBRARIES}) endif(ENABLE_LIBCURL) +if (ENABLE_NSS3) + set(poppler_SRCS ${poppler_SRCS} + poppler/SignatureHandler.cc + poppler/SignatureInfo.cc + ) + set(poppler_LIBS ${poppler_LIBS} ${NSS3_LIBRARIES}) +endif(ENABLE_NSS3) if(LIBOPENJPEG_FOUND) set(poppler_SRCS ${poppler_SRCS} poppler/JPEG2000Stream.cc @@ -727,6 +735,7 @@ show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) show_end_message_yesno("use zlib" ENABLE_ZLIB) show_end_message_yesno("use curl" ENABLE_LIBCURL) show_end_message_yesno("use libopenjpeg" WITH_OPENJPEG) +show_end_message_yesno("use nss3" ENABLE_NSS3) if(USE_OPENJPEG1) message(" with openjpeg1") endif() diff --git a/config.h.cmake b/config.h.cmake index 400b16b..b62994f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -21,6 +21,9 @@ /* Use zlib instead of builtin zlib decoder. */ #cmakedefine ENABLE_ZLIB 1 +/* Build against libnss3 for digital signature validation */ +#cmakedefine ENABLE_NSS3 1 + /* Use cairo for rendering. */ #cmakedefine HAVE_CAIRO 1 diff --git a/configure.ac b/configure.ac index 741001d..da18b23 100644 --- a/configure.ac +++ b/configure.ac @@ -264,12 +264,29 @@ else enable_libopenjpeg=no fi -PKG_CHECK_MODULES(NSS3, nss, [], []) +dnl Test for NSS +AC_ARG_ENABLE(libnss, + AC_HELP_STRING([--disable-nss], + [Do not build against libnss3.]), + enable_libnss=$enableval, + enable_libnss="try") + +if test x$enable_libnss != xno; then + PKG_CHECK_MODULES(NSS3, nss, [enable_nss="yes"], + [enable_nss="no"]) +fi + +if test x$enable_nss = xyes; then + AC_DEFINE(ENABLE_NSS3, 1, [Build against NSS.]) +fi AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$openjpeg1 = xyes || test x$openjpeg2 = xyes) AH_TEMPLATE([ENABLE_LIBOPENJPEG], [Use libopenjpeg instead of builtin jpeg2000 decoder.]) +AM_CONDITIONAL(BUILD_NSS, test x$enable_nss = xyes) +AH_TEMPLATE([ENABLE_NSS3], [Build Poppler against NSS for digital signature support.]) + dnl ##### Test for libtiff AC_ARG_ENABLE(libtiff, AC_HELP_STRING([--disable-libtiff], @@ -1007,6 +1024,7 @@ echo " use libjpeg: $enable_libjpeg" echo " use libpng: $enable_libpng" echo " use libtiff: $enable_libtiff" echo " use zlib: $enable_zlib" +echo " use nss $enable_nss" echo " use libcurl: $enable_libcurl" echo " use libopenjpeg: $enable_libopenjpeg" if test x$enable_libopenjpeg = xyes;then diff --git a/poppler/Form.cc b/poppler/Form.cc index 5bf3492..c5b7078 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -39,7 +39,9 @@ #include "Form.h" #include "PDFDoc.h" #include "DateInfo.h" +#ifdef ENABLE_NSS3 #include "SignatureHandler.h" +#endif #include "XRef.h" #include "PDFDocEncoding.h" #include "Annot.h" @@ -445,10 +447,12 @@ FormWidgetSignature::FormWidgetSignature(PDFDoc *docA, Object *aobj, unsigned nu parent = static_cast(field); } +#ifdef ENABLE_NSS3 SignatureInfo *FormWidgetSignature::validateSignature(bool doVerifyCert, bool forceRevalidation) { return parent->validateSignature(doVerifyCert, forceRevalidation); } +#endif void FormWidgetSignature::updateWidgetAppearance() { @@ -1379,18 +1383,24 @@ GooString *FormFieldChoice::getSelectedChoice() { FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set *usedParents) : FormField(docA, dict, ref, parent, usedParents, formSignature) { +#ifdef ENABLE_NSS3 signature = NULL; + signature_info = new SignatureInfo(); parseInfo(); +#endif } FormFieldSignature::~FormFieldSignature() { +#ifdef ENABLE_NSS3 byte_range.free(); delete signature_info; delete signature; +#endif } +#ifdef ENABLE_NSS3 void FormFieldSignature::parseInfo() { if (!obj.isDict()) @@ -1500,6 +1510,7 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for return signature_info; } +#endif #ifdef DEBUG_FORMS void FormFieldSignature::print(int indent) diff --git a/poppler/Form.h b/poppler/Form.h index ff4dc1e..e99e60f 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -250,7 +250,9 @@ public: FormWidgetSignature(PDFDoc *docA, Object *dict, unsigned num, Ref ref, FormField *p); void updateWidgetAppearance(); +#ifdef ENABLE_NSS3 SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation); +#endif protected: FormFieldSignature *parent; @@ -494,19 +496,24 @@ class FormFieldSignature: public FormField { public: FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set *usedParents); +#ifdef ENABLE_NSS3 SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation); +#endif virtual ~FormFieldSignature(); +#ifdef DEBUG_FORMS + void print(int indent = 0); +#endif + +#ifdef ENABLE_NSS3 private: void parseInfo(); Object byte_range; GooString *signature; SignatureInfo *signature_info; - -#ifdef DEBUG_FORMS - void print(int indent = 0); #endif + }; //------------------------------------------------------------------------ diff --git a/poppler/Makefile.am b/poppler/Makefile.am index 2d8c5e6..919928e 100644 --- a/poppler/Makefile.am +++ b/poppler/Makefile.am @@ -78,6 +78,24 @@ libjpeg2000_sources = \ endif +if BUILD_NSS + +nss_sources = \ + SignatureHandler.cc \ + SignatureInfo.cc + +nss_libs = \ + $(NSS3_LIBS) + +nss_includes = \ + $(NSS3_CFLAGS) + +nss_headers = + SignatureHandler.h \ + SignatureInfo.h + +endif + if BUILD_ZLIB @@ -119,6 +137,7 @@ poppler_includedir = $(includedir)/poppler poppler_include_HEADERS = \ $(splash_headers) \ $(curl_headers) \ + $(nss_headers) \ Annot.h \ Array.h \ BuiltinFont.h \ @@ -166,8 +185,6 @@ poppler_include_HEADERS = \ PreScanOutputDev.h \ PSTokenizer.h \ Rendition.h \ - SignatureHandler.h \ - SignatureInfo.h \ StdinCachedFile.h \ StdinPDFDocBuilder.h \ Stream-CCITT.h \ @@ -202,6 +219,7 @@ libpoppler_la_SOURCES = \ $(splash_sources) \ $(libjpeg_sources) \ $(zlib_sources) \ + $(nss_sources) \ $(libjpeg2000_sources) \ $(curl_sources) \ Annot.cc \ @@ -249,8 +267,6 @@ libpoppler_la_SOURCES = \ PreScanOutputDev.cc \ PSTokenizer.cc \ Rendition.cc \ - SignatureHandler.cc \ - SignatureInfo.cc \ StdinCachedFile.cc \ StdinPDFDocBuilder.cc \ Stream.cc \ @@ -279,7 +295,7 @@ libpoppler_la_CPPFLAGS = \ $(libjpeg2000_includes) \ $(libpng_includes) \ $(libcurl_includes) \ - $(NSS3_CFLAGS) \ + $(nss_includes) \ $(FREETYPE_CFLAGS) \ $(FONTCONFIG_CFLAGS) \ $(AM_CPPFLAGS) @@ -294,8 +310,8 @@ libpoppler_la_LIBADD = \ $(libpng_libs) \ $(zlib_libs) \ $(libcurl_libs) \ + $(nss_libs) \ $(libjpeg2000_libs) \ - $(NSS3_LIBS) \ $(FREETYPE_LIBS) \ $(FONTCONFIG_LIBS) \ $(PTHREAD_LIBS) \ diff --git a/poppler/poppler-config.h.cmake b/poppler/poppler-config.h.cmake index b087a69..b84c3bf 100644 --- a/poppler/poppler-config.h.cmake +++ b/poppler/poppler-config.h.cmake @@ -71,6 +71,11 @@ #cmakedefine ENABLE_LIBJPEG 1 #endif +/* Build against libnss3 for digital signature validation */ +#ifndef ENABLE_NSS3 +#cmakedefine ENABLE_NSS3 1 +#endif + /* Build against libtiff. */ #ifndef ENABLE_LIBTIFF #cmakedefine ENABLE_LIBTIFF 1 diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index ea56bd2..8155cb2 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -89,13 +89,15 @@ target_link_libraries(pdfinfo ${common_libs}) install(TARGETS pdfinfo DESTINATION bin) install(FILES pdfinfo.1 DESTINATION ${SHARE_INSTALL_DIR}/man/man1) -# pdfsigverify -set(pdfsigverify_SOURCES ${common_srcs} - pdfsigverify.cc -) -add_executable(pdfsigverify ${pdfsigverify_SOURCES}) -target_link_libraries(pdfsigverify ${common_libs}) -install(TARGETS pdfsigverify DESTINATION bin) +if (ENABLE_NSS3) + # pdfsigverify + set(pdfsigverify_SOURCES ${common_srcs} + pdfsigverify.cc + ) + add_executable(pdfsigverify ${pdfsigverify_SOURCES}) + target_link_libraries(pdfsigverify ${common_libs}) + install(TARGETS pdfsigverify DESTINATION bin) +endif (ENABLE_NSS3) # pdftops set(pdftops_SOURCES ${common_srcs} diff --git a/utils/Makefile.am b/utils/Makefile.am index 318cfb6..2ddcca0 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -23,9 +23,12 @@ bin_PROGRAMS = \ pdftotext \ pdftohtml \ pdfseparate \ - pdfsigverify \ pdfunite +if BUILD_NSS +bin_PROGRAMS += pdfsigverify +endif + if BUILD_SPLASH_OUTPUT bin_PROGRAMS += pdftoppm endif