Skip to content

Commit a34b47f

Browse files
committed
WL#15524 Patch #1 "START TLS" for management API
Post push fix. Remove added C++ dependencies in C header mgmapi.h. - forward declare SSL_CTX. - add missing struct keyword with ndb_mgm_cert_table and ndb_mgm_tls_stats - make ndb_mgm_set_ssl_ctx return int instead of bool as other mgmapi functions do. Change-Id: I493b4c4fb1272974e1bb72e35abb08c8cef1a534
1 parent 09859f5 commit a34b47f

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

storage/ndb/include/mgmapi/mgmapi.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@
170170
extern "C" {
171171
#endif
172172

173+
/*
174+
* ssl_ctx_ct is explicitly declared to allow API also be used when user
175+
* application do not explicitly use OpenSSL and do not have header files like
176+
* openssl/ossl_typ.h or openssl/types.h installed.
177+
*
178+
* SSL_CTX is an alias for struct ssl_ctx_st in OpenSSL.
179+
*/
180+
struct ssl_ctx_st;
181+
173182
/**
174183
* The NdbMgmHandle.
175184
*/
@@ -1585,10 +1594,10 @@ extern "C" {
15851594
* @param handle Management handle
15861595
* @param ctx SSL_ctx to be used for TLS and HTTPS connections
15871596
*
1588-
* @return True on success, false if ctx has already been set
1597+
* @return 0 on success, -1 if ctx has already been set
15891598
*
15901599
*/
1591-
bool ndb_mgm_set_ssl_ctx(NdbMgmHandle handle, struct ssl_ctx_st *ctx);
1600+
int ndb_mgm_set_ssl_ctx(NdbMgmHandle handle, struct ssl_ctx_st *ctx);
15921601

15931602
/**
15941603
* Start TLS. Upgrade an open, unencrypted connection to a secure one.
@@ -1664,12 +1673,12 @@ extern "C" {
16641673
* On return, list will be populated with a pointer to a table. The table
16651674
* should be freed after use by calling ndb\_mgm\_cert\_table\_free().
16661675
*/
1667-
int ndb_mgm_list_certs(NdbMgmHandle, ndb_mgm_cert_table ** list);
1676+
int ndb_mgm_list_certs(NdbMgmHandle, struct ndb_mgm_cert_table ** list);
16681677

16691678
/**
16701679
* Free a linked list of certificate descriptions.
16711680
*/
1672-
void ndb_mgm_cert_table_free(ndb_mgm_cert_table ** list);
1681+
void ndb_mgm_cert_table_free(struct ndb_mgm_cert_table ** list);
16731682

16741683
/**
16751684
* Struct ndb\_mgm\_tls\_stats stores TLS-related statistics from the server.
@@ -1689,7 +1698,7 @@ extern "C" {
16891698
*
16901699
* @return 0 on success, -1 on error
16911700
*/
1692-
int ndb_mgm_get_tls_stats(NdbMgmHandle handle, ndb_mgm_tls_stats * result);
1701+
int ndb_mgm_get_tls_stats(NdbMgmHandle handle, struct ndb_mgm_tls_stats * result);
16931702

16941703
#ifdef __cplusplus
16951704
}

storage/ndb/src/mgmapi/mgmapi.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,14 +2667,14 @@ ndb_mgm_get_configuration_from_node(NdbMgmHandle handle,
26672667
}
26682668

26692669
extern "C"
2670-
bool
2670+
int
26712671
ndb_mgm_set_ssl_ctx(NdbMgmHandle handle, struct ssl_ctx_st *ctx)
26722672
{
26732673
if(handle && (handle->ssl_ctx == nullptr)) {
26742674
handle->ssl_ctx = ctx;
2675-
return true;
2675+
return 0;
26762676
}
2677-
return false;
2677+
return -1;
26782678
}
26792679

26802680
extern "C"

storage/ndb/test/ndbapi/testMgmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,9 +2141,9 @@ int runTestStartTls(NDBT_Context* ctx, NDBT_Step* step)
21412141
CHECK(ndb_mgm_get_latest_error(mgmd.handle()) == NDB_MGM_TLS_ERROR);
21422142

21432143
r = ndb_mgm_set_ssl_ctx(mgmd.handle(), tls_km.ctx());
2144-
CHECK(r); // first time setting ctx succeeds
2144+
CHECK(r == 0); // first time setting ctx succeeds
21452145
r = ndb_mgm_set_ssl_ctx(mgmd.handle(), nullptr);
2146-
CHECK(r == 0); // second time setting ctx fails
2146+
CHECK(r == -1); // second time setting ctx fails
21472147

21482148
r = ndb_mgm_start_tls(mgmd.handle());
21492149
printf("ndb_mgm_start_tls(): %d\n", r);

0 commit comments

Comments
 (0)