@@ -46,13 +46,14 @@ public KafkaWebsocketServer(Properties wsProps, Properties consumerProps, Proper
46
46
}
47
47
48
48
private SslContextFactory newSslContextFactory () {
49
+ LOG .info ("Configuring TLS." );
49
50
String keyStorePath = wsProps .getProperty ("ws.ssl.keyStorePath" );
50
51
String keyStorePassword = wsProps .getProperty ("ws.ssl.keyStorePassword" );
51
52
String trustStorePath = wsProps .getProperty ("ws.ssl.trustStorePath" , keyStorePath );
52
53
String trustStorePassword = wsProps .getProperty ("ws.ssl.trustStorePassword" , keyStorePassword );
53
54
String [] protocols = wsProps .getProperty ("ws.ssl.protocols" , DEFAULT_PROTOCOLS ).split ("," );
54
55
String [] ciphers = wsProps .getProperty ("ws.ssl.ciphers" , DEFAULT_CIPHERS ).split ("," );
55
- Boolean clientAuth = Boolean . parseBoolean ( wsProps .getProperty ("ws.ssl.clientAuth" , "false" ) );
56
+ String clientAuth = wsProps .getProperty ("ws.ssl.clientAuth" , "none" );
56
57
57
58
SslContextFactory sslContextFactory = new SslContextFactory ();
58
59
sslContextFactory .setKeyStorePath (keyStorePath );
@@ -62,8 +63,23 @@ private SslContextFactory newSslContextFactory() {
62
63
sslContextFactory .setTrustStorePassword (trustStorePassword );
63
64
sslContextFactory .setIncludeProtocols (protocols );
64
65
sslContextFactory .setIncludeCipherSuites (ciphers );
65
- sslContextFactory .setNeedClientAuth (clientAuth );
66
- sslContextFactory .setValidatePeerCerts (clientAuth );
66
+ switch (clientAuth ) {
67
+ case "required" :
68
+ LOG .info ("Client auth required." );
69
+ sslContextFactory .setNeedClientAuth (true );
70
+ sslContextFactory .setValidatePeerCerts (true );
71
+ break ;
72
+ case "optional" :
73
+ LOG .info ("Client auth allowed." );
74
+ sslContextFactory .setWantClientAuth (true );
75
+ sslContextFactory .setValidatePeerCerts (true );
76
+ break ;
77
+ default :
78
+ LOG .info ("Client auth disabled." );
79
+ sslContextFactory .setNeedClientAuth (false );
80
+ sslContextFactory .setWantClientAuth (false );
81
+ sslContextFactory .setValidatePeerCerts (false );
82
+ }
67
83
return sslContextFactory ;
68
84
}
69
85
0 commit comments