@@ -123,6 +123,8 @@ public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
123123
124124    private  boolean  isEnterprise  = false ;
125125
126+     private  boolean  hasTlsPorts  = false ;
127+ 
126128    /** 
127129     * Creates a new couchbase container with the default image and version. 
128130     * @deprecated use {@link #CouchbaseContainer(DockerImageName)} instead 
@@ -345,6 +347,7 @@ protected void containerIsStarting(final InspectContainerResponse containerInfo)
345347
346348        timePhase ("waitUntilNodeIsOnline" , this ::waitUntilNodeIsOnline );
347349        timePhase ("initializeIsEnterprise" , this ::initializeIsEnterprise );
350+         timePhase ("initializeHasTlsPorts" , this ::initializeHasTlsPorts );
348351        timePhase ("renameNode" , this ::renameNode );
349352        timePhase ("initializeServices" , this ::initializeServices );
350353        timePhase ("setMemoryQuotas" , this ::setMemoryQuotas );
@@ -394,6 +397,31 @@ private void initializeIsEnterprise() {
394397        }
395398    }
396399
400+     /** 
401+      * Initializes the {@link #hasTlsPorts} flag. 
402+      * <p> 
403+      * Community Edition might support TLS one happy day, so use a "supports TLS" flag separate from 
404+      * the "enterprise edition" flag. 
405+      */ 
406+     private  void  initializeHasTlsPorts () {
407+         @ Cleanup 
408+         Response  response  = doHttpRequest (MGMT_PORT , "/pools/default/nodeServices" , "GET" , null , true );
409+ 
410+         try  {
411+             String  clusterTopology  = response .body ().string ();
412+             hasTlsPorts  =
413+                 !MAPPER 
414+                     .readTree (clusterTopology )
415+                     .path ("nodesExt" )
416+                     .path (0 )
417+                     .path ("services" )
418+                     .path ("mgmtSSL" )
419+                     .isMissingNode ();
420+         } catch  (IOException  e ) {
421+             throw  new  IllegalStateException ("Couchbase /pools/default/nodeServices did not return valid JSON" );
422+         }
423+     }
424+ 
397425    /** 
398426     * Rebinds/renames the internal hostname. 
399427     * <p> 
@@ -503,33 +531,45 @@ private void configureExternalPorts() {
503531        final  FormBody .Builder  builder  = new  FormBody .Builder ();
504532        builder .add ("hostname" , getHost ());
505533        builder .add ("mgmt" , Integer .toString (getMappedPort (MGMT_PORT )));
506-         builder .add ("mgmtSSL" , Integer .toString (getMappedPort (MGMT_SSL_PORT )));
534+         if  (hasTlsPorts ) {
535+             builder .add ("mgmtSSL" , Integer .toString (getMappedPort (MGMT_SSL_PORT )));
536+         }
507537
508538        if  (enabledServices .contains (CouchbaseService .KV )) {
509539            builder .add ("kv" , Integer .toString (getMappedPort (KV_PORT )));
510-             builder .add ("kvSSL" , Integer .toString (getMappedPort (KV_SSL_PORT )));
511540            builder .add ("capi" , Integer .toString (getMappedPort (VIEW_PORT )));
512-             builder .add ("capiSSL" , Integer .toString (getMappedPort (VIEW_SSL_PORT )));
541+             if  (hasTlsPorts ) {
542+                 builder .add ("kvSSL" , Integer .toString (getMappedPort (KV_SSL_PORT )));
543+                 builder .add ("capiSSL" , Integer .toString (getMappedPort (VIEW_SSL_PORT )));
544+             }
513545        }
514546
515547        if  (enabledServices .contains (CouchbaseService .QUERY )) {
516548            builder .add ("n1ql" , Integer .toString (getMappedPort (QUERY_PORT )));
517-             builder .add ("n1qlSSL" , Integer .toString (getMappedPort (QUERY_SSL_PORT )));
549+             if  (hasTlsPorts ) {
550+                 builder .add ("n1qlSSL" , Integer .toString (getMappedPort (QUERY_SSL_PORT )));
551+             }
518552        }
519553
520554        if  (enabledServices .contains (CouchbaseService .SEARCH )) {
521555            builder .add ("fts" , Integer .toString (getMappedPort (SEARCH_PORT )));
522-             builder .add ("ftsSSL" , Integer .toString (getMappedPort (SEARCH_SSL_PORT )));
556+             if  (hasTlsPorts ) {
557+                 builder .add ("ftsSSL" , Integer .toString (getMappedPort (SEARCH_SSL_PORT )));
558+             }
523559        }
524560
525561        if  (enabledServices .contains (CouchbaseService .ANALYTICS )) {
526562            builder .add ("cbas" , Integer .toString (getMappedPort (ANALYTICS_PORT )));
527-             builder .add ("cbasSSL" , Integer .toString (getMappedPort (ANALYTICS_SSL_PORT )));
563+             if  (hasTlsPorts ) {
564+                 builder .add ("cbasSSL" , Integer .toString (getMappedPort (ANALYTICS_SSL_PORT )));
565+             }
528566        }
529567
530568        if  (enabledServices .contains (CouchbaseService .EVENTING )) {
531569            builder .add ("eventingAdminPort" , Integer .toString (getMappedPort (EVENTING_PORT )));
532-             builder .add ("eventingSSL" , Integer .toString (getMappedPort (EVENTING_SSL_PORT )));
570+             if  (hasTlsPorts ) {
571+                 builder .add ("eventingSSL" , Integer .toString (getMappedPort (EVENTING_SSL_PORT )));
572+             }
533573        }
534574
535575        @ Cleanup 
0 commit comments