diff --git a/src/makefile.am b/src/makefile.am index 151fb91..9027d5c 100644 --- a/src/makefile.am +++ b/src/makefile.am @@ -32,6 +32,10 @@ libcryptoki___la_LIBADD += -lpcsclite endif endif +noinst_PROGRAMS = versiontest +versiontest_SOURCES = versiontest.cxx + + clean-local: -rm -r ${QMAKE_TARGET}.app diff --git a/src/openssl.hxx b/src/openssl.hxx index fc9d8e3..af45769 100644 --- a/src/openssl.hxx +++ b/src/openssl.hxx @@ -23,9 +23,13 @@ #elif OPENSSL_VERSION_NUMBER < 0x10000000L # define OPENSSL_0 # define V0_CONST const +# define CV_STACK +# define CV_X509 #else # define OPENSSL_1 -# define V0_CONST /* no const in openssl 1.0.0 */ +# define V0_CONST const +# define CV_STACK (_STACK*) +# define CV_X509 (STACK_OF(X509)*) #endif #include // BASIC_CONSTRAINTS @@ -1071,8 +1075,8 @@ namespace openssl { throw pkcs12_parsing_failed(filename); if (pkey) _key = new PrivateKey(pkey); if (cert) _cert = new X509(cert); - for (int i(sk_num(ca)); i>0; --i) - _ca.push_back(new X509((::X509*)sk_pop(ca))); + for (int i(sk_num(CV_STACK ca)); i>0; --i) + _ca.push_back(new X509((::X509*)sk_pop(CV_STACK ca))); PKCS12_free(p12); } catch (...) { PKCS12_free(p12); @@ -1160,8 +1164,8 @@ namespace openssl { BIO_free(mem); if (!p7) throw pkcs7_parsing_failed(); try { - if (PKCS7_type_is_signed(p7)) while (p7->d.sign->cert->num>0) - _certs.push_back(new X509((::X509*)sk_pop(p7->d.sign->cert))); + if (PKCS7_type_is_signed(p7)) while ((CV_STACK p7->d.sign->cert)->num>0) + _certs.push_back(new X509((::X509*)sk_pop(CV_STACK p7->d.sign->cert))); else //! @todo to be implemented: check for other types throw pkcs7_unsupported_format(); PKCS7_free(p7); diff --git a/src/versiontest.cxx b/src/versiontest.cxx new file mode 100644 index 0000000..125c01e --- /dev/null +++ b/src/versiontest.cxx @@ -0,0 +1,16 @@ +#include +#ifndef OPENSSL_VERSION_NUMBER +# error OpenSSL Version Number not Found +#elif OPENSSL_VERSION_NUMBER < 0x10000000L +# define NAME "an old pre 1.0.0 version of OpenSSL" +#else +# define NAME "a new 1.0.x version of OpenSSL" +#endif + +#include +#include + +int main() { + std::cout<