version checker and changes for openssl 1.0.0; refs #6
This commit is contained in:
@@ -32,6 +32,10 @@ libcryptoki___la_LIBADD += -lpcsclite
|
||||
endif
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = versiontest
|
||||
versiontest_SOURCES = versiontest.cxx
|
||||
|
||||
|
||||
clean-local:
|
||||
-rm -r ${QMAKE_TARGET}.app
|
||||
|
||||
|
@@ -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 <openssl/x509v3.h> // 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);
|
||||
|
16
src/versiontest.cxx
Normal file
16
src/versiontest.cxx
Normal file
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user