3737import org .apache .zookeeper .metrics .Gauge ;
3838import org .apache .zookeeper .metrics .GaugeSet ;
3939import org .apache .zookeeper .metrics .MetricsContext ;
40- import org .apache .zookeeper .metrics .MetricsContext .DetailLevel ;
4140import org .apache .zookeeper .metrics .MetricsProvider ;
4241import org .apache .zookeeper .metrics .MetricsProviderLifeCycleException ;
4342import org .apache .zookeeper .metrics .Summary ;
@@ -83,8 +82,14 @@ public class PrometheusMetricsProvider implements MetricsProvider {
8382 private String trustStoreType ;
8483 private boolean needClientAuth = true ; // Secure default
8584 private boolean wantClientAuth = true ; // Secure default
85+ private String enabledProtocols ;
86+ private String cipherSuites ;
8687
8788 // Constants for configuration
89+ public static final String HTTP_HOST = "httpHost" ;
90+ public static final String HTTP_PORT = "httpPort" ;
91+ public static final String EXPORT_JVM_INFO = "exportJvmInfo" ;
92+ public static final String HTTPS_PORT = "httpsPort" ;
8893 public static final String NUM_WORKER_THREADS = "numWorkerThreads" ;
8994 public static final String SSL_KEYSTORE_LOCATION = "ssl.keyStore.location" ;
9095 public static final String SSL_KEYSTORE_PASSWORD = "ssl.keyStore.password" ;
@@ -94,6 +99,8 @@ public class PrometheusMetricsProvider implements MetricsProvider {
9499 public static final String SSL_TRUSTSTORE_TYPE = "ssl.trustStore.type" ;
95100 public static final String SSL_NEED_CLIENT_AUTH = "ssl.need.client.auth" ;
96101 public static final String SSL_WANT_CLIENT_AUTH = "ssl.want.client.auth" ;
102+ public static final String SSL_ENABLED_PROTOCOLS = "ssl.enabledProtocols" ;
103+ public static final String SSL_ENABLED_CIPHERS = "ssl.ciphersuites" ;
97104 public static final int SCAN_INTERVAL = 60 * 10 ; // 10 minutes
98105
99106 /**
@@ -114,10 +121,10 @@ protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws
114121 public void configure (Properties configuration ) throws MetricsProviderLifeCycleException {
115122 LOG .info ("Initializing Prometheus metrics with Jetty, configuration: {}" , configuration );
116123
117- this .host = configuration .getProperty ("httpHost" , "0.0.0.0" );
118- this .httpPort = Integer .parseInt (configuration .getProperty ("httpPort" , "-1" ));
119- this .httpsPort = Integer .parseInt (configuration .getProperty ("httpsPort" , "-1" ));
120- this .exportJvmInfo = Boolean .parseBoolean (configuration .getProperty ("exportJvmInfo" , "true" ));
124+ this .host = configuration .getProperty (HTTP_HOST , "0.0.0.0" );
125+ this .httpPort = Integer .parseInt (configuration .getProperty (HTTP_PORT , "-1" ));
126+ this .httpsPort = Integer .parseInt (configuration .getProperty (HTTPS_PORT , "-1" ));
127+ this .exportJvmInfo = Boolean .parseBoolean (configuration .getProperty (EXPORT_JVM_INFO , "true" ));
121128 this .numWorkerThreads = Integer .parseInt (configuration .getProperty (NUM_WORKER_THREADS , "10" ));
122129
123130 // If httpsPort is specified, parse all SSL properties
@@ -130,6 +137,8 @@ public void configure(Properties configuration) throws MetricsProviderLifeCycleE
130137 this .trustStoreType = configuration .getProperty (SSL_TRUSTSTORE_TYPE , "PKCS12" );
131138 this .needClientAuth = Boolean .parseBoolean (configuration .getProperty (SSL_NEED_CLIENT_AUTH , "true" ));
132139 this .wantClientAuth = Boolean .parseBoolean (configuration .getProperty (SSL_WANT_CLIENT_AUTH , "true" ));
140+ this .enabledProtocols = configuration .getProperty (SSL_ENABLED_PROTOCOLS );
141+ this .cipherSuites = configuration .getProperty (SSL_ENABLED_CIPHERS );
133142 }
134143
135144 // Validate that at least one port is configured.
@@ -232,6 +241,18 @@ private SslContextFactory.Server createSslContextFactory() {
232241 sslContextFactory .setNeedClientAuth (this .needClientAuth );
233242 sslContextFactory .setWantClientAuth (this .wantClientAuth );
234243
244+ if (enabledProtocols != null ) {
245+ LOG .debug ("Setting enabled protocols: '{}'" , enabledProtocols );
246+ String [] enabledProtocolsArray = enabledProtocols .split ("," );
247+ sslContextFactory .setIncludeProtocols (enabledProtocolsArray );
248+ }
249+
250+ if (cipherSuites != null ) {
251+ LOG .debug ("Setting enabled cipherSuites: '{}'" , cipherSuites );
252+ String [] cipherSuitesArray = cipherSuites .split ("," );
253+ sslContextFactory .setIncludeCipherSuites (cipherSuitesArray );
254+ }
255+
235256 return sslContextFactory ;
236257 }
237258
0 commit comments