Skip to content

Commit 116a05f

Browse files
committed
WL#15135 patch #6: Configure TLS in Cluster/J
Part of WL#15135 Certificate Architecture Add Jtie mappings for Ndb_cluster_connection.configure_tls(). Add native method configure_tls() to Java class Ndb_cluster_connection. Add public Java method configureTls to interface ClusterConnection in clusterj-core. Map the TLS search path to a new Cluster/J connection property, com.mysql.clusterj.tls.path Cluster/J test cases will come as part of later worklogs. Change-Id: Id193d9a33a47eb7638abc58184fb990dca95db75
1 parent dd04c80 commit 116a05f

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

storage/ndb/clusterj/clusterj-api/src/main/java/com/mysql/clusterj/Constants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public interface Constants {
4040
*/
4141
static final String PROPERTY_CLUSTER_CONNECTSTRING = "com.mysql.clusterj.connectstring";
4242

43+
/*** The name of the TLS Search Path property. */
44+
static final String PROPERTY_TLS_SEARCH_PATH = "com.mysql.clusterj.tls.path";
45+
46+
/** The default value of the TLS Search Path property. */
47+
static final String DEFAULT_PROPERTY_TLS_SEARCH_PATH = "$HOME/ndb-tls";
48+
4349
/** The name of the initial timeout for cluster connection to connect to MGM before connecting to data nodes
4450
* <a href="http://dev.mysql.com/doc/ndbapi/en/ndb-ndb-cluster-connection.html#ndb-ndb-cluster-connection-set-timeout">Ndb_cluster_connection::set_timeout()</a>
4551
*/

storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/SessionFactoryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class SessionFactoryImpl implements SessionFactory, Constants {
7575
/** NdbCluster connect properties */
7676
String CLUSTER_CONNECTION_SERVICE;
7777
String CLUSTER_CONNECT_STRING;
78+
String CLUSTER_TLS_SEARCH_PATH;
7879
int CLUSTER_CONNECT_TIMEOUT_MGM;
7980
int CLUSTER_CONNECT_RETRIES;
8081
int CLUSTER_CONNECT_DELAY;
@@ -189,6 +190,8 @@ protected SessionFactoryImpl(Map<?, ?> props) {
189190
CLUSTER_RECONNECT_TIMEOUT = getIntProperty(props,
190191
PROPERTY_CONNECTION_RECONNECT_TIMEOUT, DEFAULT_PROPERTY_CONNECTION_RECONNECT_TIMEOUT);
191192
CLUSTER_CONNECT_STRING = getRequiredStringProperty(props, PROPERTY_CLUSTER_CONNECTSTRING);
193+
CLUSTER_TLS_SEARCH_PATH = getStringProperty(props, PROPERTY_TLS_SEARCH_PATH,
194+
Constants.DEFAULT_PROPERTY_TLS_SEARCH_PATH);
192195
CLUSTER_CONNECT_RETRIES = getIntProperty(props, PROPERTY_CLUSTER_CONNECT_RETRIES,
193196
Constants.DEFAULT_PROPERTY_CLUSTER_CONNECT_RETRIES);
194197
CLUSTER_CONNECT_TIMEOUT_MGM = getIntProperty(props, PROPERTY_CLUSTER_CONNECT_TIMEOUT_MGM,
@@ -361,6 +364,7 @@ protected ClusterConnection createClusterConnection(
361364
try {
362365
result = service.create(CLUSTER_CONNECT_STRING, nodeId, CLUSTER_CONNECT_TIMEOUT_MGM);
363366
result.setByteBufferPoolSizes(CLUSTER_BYTE_BUFFER_POOL_SIZES);
367+
result.configureTls(CLUSTER_TLS_SEARCH_PATH, 0);
364368
result.connect(CLUSTER_CONNECT_RETRIES, CLUSTER_CONNECT_DELAY,true);
365369
result.waitUntilReady(CLUSTER_CONNECT_TIMEOUT_BEFORE,CLUSTER_CONNECT_TIMEOUT_AFTER);
366370
// Cluster connection successful.

storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/store/ClusterConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public interface ClusterConnection {
3535

3636
public Db createDb(String database, int maxTransactions);
3737

38+
public void configureTls(String searchPath, int requirement);
39+
3840
public void waitUntilReady(int connectTimeoutBefore, int connectTimeoutAfter);
3941

4042
public void closing();

storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ public Db createDb(String database, int maxTransactions) {
175175
return result;
176176
}
177177

178+
public void configureTls(String tlsSearchPath, int tlsRequirement) {
179+
if(tlsSearchPath == null) tlsSearchPath = "";
180+
clusterConnection.configure_tls(tlsSearchPath, tlsRequirement);
181+
}
182+
178183
public void waitUntilReady(int connectTimeoutBefore, int connectTimeoutAfter) {
179184
checkConnection();
180185
int returnCode = clusterConnection.wait_until_ready(connectTimeoutBefore, connectTimeoutAfter);

storage/ndb/src/ndbjtie/NdbApiWrapper.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,6 +3541,13 @@ struct NdbApiWrapper {
35413541
return obj.set_timeout(p0);
35423542
}
35433543

3544+
static void
3545+
Ndb_cluster_connection__configure_tls
3546+
( Ndb_cluster_connection & obj, const char * p1, int p2)
3547+
{
3548+
return obj.configure_tls(p1, p2);
3549+
}
3550+
35443551
static int
35453552
Ndb_cluster_connection__connect
35463553
( Ndb_cluster_connection & obj, int p0, int p1, int p2 )

storage/ndb/src/ndbjtie/com/mysql/ndbjtie/ndbapi/Ndb_cluster_connection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class Ndb_cluster_connection extends Wrapper implements Ndb_cluster_conne
4040
static public final native void delete(Ndb_cluster_connection p0);
4141
public final native void set_name(String/*_const char *_*/ name);
4242
public final native void set_application_port(int port);
43+
public final native void configure_tls(String searchPath, int requirement);
4344
public final native int set_timeout(int timeout_ms);
4445
public final native int connect(int no_retries /*_= 0_*/, int retry_delay_in_seconds /*_= 1_*/, int verbose /*_= 0_*/);
4546
public final native int wait_until_ready(int timeout_for_first_alive, int timeout_after_first_alive);

storage/ndb/src/ndbjtie/ndbapi_jtie.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10241,6 +10241,21 @@ Java_com_mysql_ndbjtie_ndbapi_Ndb_1cluster_1connection_set_1timeout(JNIEnv * env
1024110241
#endif // NDBJTIE_USE_WRAPPED_VARIANT_FOR_FUNCTION
1024210242
}
1024310243

10244+
/*
10245+
* Class: com_mysql_ndbjtie_ndbapi_Ndb_cluster_connection
10246+
* Method: configure_tls
10247+
*/
10248+
JNIEXPORT void JNICALL
10249+
Java_com_mysql_ndbjtie_ndbapi_Ndb_1cluster_1connection_configure_1tls(JNIEnv * env, jobject obj, jstring p0, jint p1)
10250+
{
10251+
TRACE("void Java_com_mysql_ndbjtie_ndbapi_Ndb_1cluster_1connection_configure_tls(JNIEnv * env, jobject obj, jstring p0, jint p1)");
10252+
#ifndef NDBJTIE_USE_WRAPPED_VARIANT_FOR_FUNCTION
10253+
return gcall_mfv< ttrait_c_m_n_n_Ndb_cluster_connection_t, ttrait_char_cp_jutf8null, ttrait_int, &Ndb_cluster_connection::configure_tls>(env, obj, p0, p1);
10254+
#else
10255+
return gcall_fv< ttrait_c_m_n_n_Ndb_cluster_connection_r, ttrait_char_cp_jutf8null, ttrait_int, &NdbApiWrapper::Ndb_cluster_connection__configure_tls>(env, NULL, obj, p0, p1);
10256+
#endif // NDBJTIE_USE_WRAPPED_VARIANT_FOR_FUNCTION
10257+
}
10258+
1024410259
/*
1024510260
* Class: com_mysql_ndbjtie_ndbapi_Ndb_cluster_connection
1024610261
* Method: connect

0 commit comments

Comments
 (0)