Skip to content

Commit 88d1edb

Browse files
committed
WL#15135 post-push fix
Add stub functions to allow NodeCertificate.cpp to compile succesfully on EL7 with OpenSSL 1.0.2. Change-Id: I882743ea6f652847b2205a94f60b6d03e2a2f478
1 parent 116a05f commit 88d1edb

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

storage/ndb/include/util/ndb_openssl3_compat.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#ifndef NDB_PORTLIB_OPENSSL_COMPAT_H
3131
#define NDB_PORTLIB_OPENSSL_COMPAT_H
3232
#include <openssl/ssl.h>
33-
33+
#include "portlib/ndb_openssl_version.h"
3434

3535
#if OPENSSL_VERSION_NUMBER < 0x30000000L && OPENSSL_VERSION_NUMBER > 0x10002000L
3636

@@ -44,4 +44,27 @@ EVP_PKEY * EVP_EC_generate(const char * curve);
4444

4545
#endif /* OPENSSL_VERSION_NUMBER */
4646

47+
/* These stub functions allow NodeCertificate.cpp to compile with old OpenSSL */
48+
#if OPENSSL_VERSION_NUMBER < NDB_TLS_MINIMUM_OPENSSL
49+
#include <openssl/x509.h>
50+
#include <openssl/x509v3.h>
51+
const ASN1_INTEGER *X509_get0_serialNumber(const X509 *);
52+
53+
#ifndef X509_getm_notBefore
54+
#define X509_getm_notBefore X509_get_notBefore
55+
#define X509_getm_notAfter X509_get_notAfter
56+
#endif
57+
58+
EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *);
59+
void X509_get0_signature(const ASN1_BIT_STRING **, const X509_ALGOR **,
60+
const X509 *);
61+
int X509_get_signature_info(X509 *, int *, int *, int *, uint32_t *);
62+
X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *,
63+
X509V3_CTX *, int, const char *);
64+
int ASN1_TIME_to_tm(const ASN1_TIME *, struct tm *);
65+
int EVP_PKEY_up_ref(EVP_PKEY *);
66+
int X509_up_ref(X509 *);
67+
68+
#endif
69+
4770
#endif /* NDB_PORTLIB_OPENSSL_COMPAT_H */

storage/ndb/src/common/util/NodeCertificate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ int PkiFile::assign(PathName & path, const char * dir, const char * file) {
7878
static void expand(BaseString & result, const BaseString & path, int envStart) {
7979
const char * item = path.c_str();
8080
size_t envEnd = envStart + 1;
81-
char c;
82-
do {
81+
char c = item[envEnd];
82+
while(isalnum(c) || c == '_') {
8383
envEnd++;
8484
c = item[envEnd];
85-
} while(isalnum(c) || c == '_');
85+
}
8686

8787
BaseString envVar = path.substr(envStart + 1, envEnd);
8888
if(envStart > 0)
@@ -1393,7 +1393,7 @@ static int cert_lifetime_test() {
13931393
CertLifetime c2;
13941394
c2.set_lifetime(20, 0);
13951395
t2 = c2.replace_time(5) - time(&t1);
1396-
printf("t2: %ld, days: %ld \n", t2, t2/CertLifetime::SecondsPerDay);
1396+
printf("t2: %ld days\n", (long) t2/CertLifetime::SecondsPerDay);
13971397
if(t2 != five_days) return 9;
13981398

13991399
/* Write lifetime to certificate */

storage/ndb/src/common/util/ndb_openssl3_compat.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,46 @@ int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b) {
100100

101101
#endif
102102

103+
/* Stub functions to allow NodeCertificate.cpp to compile with old OpenSSL */
104+
#if OPENSSL_VERSION_NUMBER < NDB_TLS_MINIMUM_OPENSSL
105+
106+
const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x) {
107+
return X509_get_serialNumber(const_cast<X509 *>(x));
108+
}
109+
110+
EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *csr) {
111+
EVP_PKEY * key = X509_REQ_get_pubkey(csr);
112+
if(key)
113+
EVP_PKEY_free(key);
114+
return key;
115+
}
116+
117+
void X509_get0_signature(const ASN1_BIT_STRING ** sig, const X509_ALGOR ** alg,
118+
const X509 * x) {
119+
X509_get0_signature(sig, const_cast<X509_ALGOR **>(alg), x);
120+
}
121+
122+
int X509_get_signature_info(X509 *, int *, int *, int *, uint32_t *) {
123+
return 0;
124+
}
125+
126+
X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,
127+
X509V3_CTX *ctx, int ext_nid,
128+
const char *value) {
129+
return X509V3_EXT_conf_nid(conf, ctx, ext_nid, const_cast<char *>(value));
130+
}
131+
132+
int ASN1_TIME_to_tm(const ASN1_TIME *, struct tm *) {
133+
return 0;
134+
}
135+
136+
int EVP_PKEY_up_ref(EVP_PKEY *) {
137+
return 0;
138+
}
139+
140+
int X509_up_ref(X509 *) {
141+
return 0;
142+
}
143+
144+
145+
#endif

storage/ndb/src/common/util/testTlsKeyManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "util/TlsKeyManager.hpp"
4545

4646
int opt_port = 4400;
47-
short opt_last_test = INT16_MAX;
47+
int opt_last_test = INT16_MAX;
4848

4949
static struct my_option options[] =
5050
{

0 commit comments

Comments
 (0)