version checker and changes for openssl 1.0.0; refs #6

master
Marc Wäckerlin 14 years ago
parent d09cb4644b
commit 5c62ed3d53
  1. 4
      src/makefile.am
  2. 14
      src/openssl.hxx
  3. 16
      src/versiontest.cxx

@ -32,6 +32,10 @@ libcryptoki___la_LIBADD += -lpcsclite
endif endif
endif endif
noinst_PROGRAMS = versiontest
versiontest_SOURCES = versiontest.cxx
clean-local: clean-local:
-rm -r ${QMAKE_TARGET}.app -rm -r ${QMAKE_TARGET}.app

@ -23,9 +23,13 @@
#elif OPENSSL_VERSION_NUMBER < 0x10000000L #elif OPENSSL_VERSION_NUMBER < 0x10000000L
# define OPENSSL_0 # define OPENSSL_0
# define V0_CONST const # define V0_CONST const
# define CV_STACK
# define CV_X509
#else #else
# define OPENSSL_1 # 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 #endif
#include <openssl/x509v3.h> // BASIC_CONSTRAINTS #include <openssl/x509v3.h> // BASIC_CONSTRAINTS
@ -1071,8 +1075,8 @@ namespace openssl {
throw pkcs12_parsing_failed(filename); throw pkcs12_parsing_failed(filename);
if (pkey) _key = new PrivateKey(pkey); if (pkey) _key = new PrivateKey(pkey);
if (cert) _cert = new X509(cert); if (cert) _cert = new X509(cert);
for (int i(sk_num(ca)); i>0; --i) for (int i(sk_num(CV_STACK ca)); i>0; --i)
_ca.push_back(new X509((::X509*)sk_pop(ca))); _ca.push_back(new X509((::X509*)sk_pop(CV_STACK ca)));
PKCS12_free(p12); PKCS12_free(p12);
} catch (...) { } catch (...) {
PKCS12_free(p12); PKCS12_free(p12);
@ -1160,8 +1164,8 @@ namespace openssl {
BIO_free(mem); BIO_free(mem);
if (!p7) throw pkcs7_parsing_failed(); if (!p7) throw pkcs7_parsing_failed();
try { try {
if (PKCS7_type_is_signed(p7)) while (p7->d.sign->cert->num>0) if (PKCS7_type_is_signed(p7)) while ((CV_STACK p7->d.sign->cert)->num>0)
_certs.push_back(new X509((::X509*)sk_pop(p7->d.sign->cert))); _certs.push_back(new X509((::X509*)sk_pop(CV_STACK p7->d.sign->cert)));
else //! @todo to be implemented: check for other types else //! @todo to be implemented: check for other types
throw pkcs7_unsupported_format(); throw pkcs7_unsupported_format();
PKCS7_free(p7); PKCS7_free(p7);

@ -0,0 +1,16 @@
#include <openssl/opensslv.h>
#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 <iostream>
#include <iomanip>
int main() {
std::cout<<std::hex<<OPENSSL_VERSION_NUMBER<<" is "<<NAME<<std::endl;
return 0;
}
Loading…
Cancel
Save