From 73ff9f1a34fc116ae1607492f388a2c63975ab87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 27 Aug 2010 09:43:20 +0000 Subject: [PATCH] first part: const or not const that is the question; refs #6 --- src/openssl.hxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/openssl.hxx b/src/openssl.hxx index c8d14d7..09fe18f 100644 --- a/src/openssl.hxx +++ b/src/openssl.hxx @@ -17,6 +17,17 @@ #include #include +#include +#ifndef OPENSSL_VERSION_NUMBER +# error OpenSSL Version Number not Found +#elif OPENSSL_VERSION_NUMBER < 0x01000000L +# define OPENSSL_0 +# define V0_CONST const +#else +# define OPENSSL_1 +# define V0_CONST /* no const in openssl 1.0.0 */ +#endif + #include // BASIC_CONSTRAINTS #include #include @@ -724,7 +735,7 @@ namespace openssl { //! Initialize from DER encoded cerificate. X509(const std::string& der): _x509(0) { OPENSSL_LOG("log"); - unsigned char* c((unsigned char*)der.begin().operator->()); + V0_CONST unsigned char* c((unsigned char*)der.begin().operator->()); if (!(_x509=d2i_X509(0, &c, der.size())) || (const char*)c!=der.begin().operator->()+der.size()) throw x509_decoding_failed(der); @@ -734,7 +745,7 @@ namespace openssl { unsigned char* d(0); int len(i2d_X509(o._x509, &d)); if (!len) throw x509_copy_failed(); - unsigned char* d2(d); + V0_CONST unsigned char* d2(d); _x509 = d2i_X509(0, &d2, len); OPENSSL_free(d); if (!_x509) throw x509_copy_failed(); @@ -755,7 +766,7 @@ namespace openssl { unsigned char* d(0); int len(i2d_X509(o._x509, &d)); if (!len) throw x509_copy_failed(); - unsigned char* d2(d); + V0_CONST unsigned char* d2(d); _x509 = d2i_X509(0, &d2, len); OPENSSL_free(d); if (!_x509) throw x509_copy_failed();