@@ -80,7 +80,6 @@ public SslContext createNettySslContextForClient(ZKConfig config)
80
80
sslContextBuilder .trustManager (tm );
81
81
}
82
82
83
- sslContextBuilder .sslProvider (getSslProvider (config ));
84
83
handleTcnativeOcspStapling (sslContextBuilder , config );
85
84
String [] enabledProtocols = getEnabledProtocols (config );
86
85
if (enabledProtocols != null ) {
@@ -90,6 +89,7 @@ public SslContext createNettySslContextForClient(ZKConfig config)
90
89
if (enabledCiphers != null ) {
91
90
sslContextBuilder .ciphers (enabledCiphers );
92
91
}
92
+ sslContextBuilder .sslProvider (getSslProvider (config ));
93
93
94
94
SslContext sslContext1 = sslContextBuilder .build ();
95
95
@@ -100,31 +100,6 @@ public SslContext createNettySslContextForClient(ZKConfig config)
100
100
}
101
101
}
102
102
103
- private SslContextBuilder handleTcnativeOcspStapling (SslContextBuilder builder , ZKConfig config ) {
104
- SslProvider sslProvider = getSslProvider (config );
105
- boolean tcnative = sslProvider == SslProvider .OPENSSL || sslProvider == SslProvider .OPENSSL_REFCNT ;
106
- boolean ocspEnabled = config .getBoolean (getSslOcspEnabledProperty ());
107
- TriState tcnativeOcspStapling = config .getTristate (getSslTcnativeOcspStaplingEnabledProperty ());
108
-
109
- if (tcnative && ocspEnabled && tcnativeOcspStapling .isDefault () && OpenSsl .isOcspSupported ()) {
110
- // Maintain old behaviour (mostly, we also check for OpenSsl.isOcspSupported())
111
- builder .enableOcsp (ocspEnabled );
112
- } else if (tcnativeOcspStapling .isTrue ()) {
113
- if (!tcnative ) {
114
- // Don't override the explicit setting, let it error out
115
- LOG .error ("Trying to enable OpenSSL OCSP stapling for non-OpenSSL TLS provider. "
116
- + "This is going to fail. Please fix the TLS configuration" );
117
- } else if (!OpenSsl .isOcspSupported ()) {
118
- LOG .warn ("Trying to enable OpenSSL OCSP stapling for OpenSSL provider {} which does not support it. "
119
- + "This is either going to be ignored or fail." , OpenSsl .versionString ());
120
- }
121
- builder .enableOcsp (true );
122
- } else if (tcnativeOcspStapling .isFalse ()) {
123
- builder .enableOcsp (false );
124
- }
125
- return builder ;
126
- }
127
-
128
103
public SslContext createNettySslContextForServer (ZKConfig config )
129
104
throws X509Exception .SSLContextException , X509Exception .KeyManagerException , X509Exception .TrustManagerException , SSLException {
130
105
String keyStoreLocation = config .getProperty (getSslKeystoreLocationProperty (), "" );
@@ -148,7 +123,7 @@ public SslContext createNettySslContextForServer(ZKConfig config, KeyManager key
148
123
if (trustManager != null ) {
149
124
sslContextBuilder .trustManager (trustManager );
150
125
}
151
- sslContextBuilder . sslProvider ( getSslProvider ( config ));
126
+
152
127
handleTcnativeOcspStapling (sslContextBuilder , config );
153
128
String [] enabledProtocols = getEnabledProtocols (config );
154
129
if (enabledProtocols != null ) {
@@ -159,6 +134,7 @@ public SslContext createNettySslContextForServer(ZKConfig config, KeyManager key
159
134
if (enabledCiphers != null ) {
160
135
sslContextBuilder .ciphers (enabledCiphers );
161
136
}
137
+ sslContextBuilder .sslProvider (getSslProvider (config ));
162
138
163
139
SslContext sslContext1 = sslContextBuilder .build ();
164
140
@@ -169,6 +145,31 @@ public SslContext createNettySslContextForServer(ZKConfig config, KeyManager key
169
145
}
170
146
}
171
147
148
+ private SslContextBuilder handleTcnativeOcspStapling (SslContextBuilder builder , ZKConfig config ) {
149
+ SslProvider sslProvider = getSslProvider (config );
150
+ boolean tcnative = sslProvider == SslProvider .OPENSSL || sslProvider == SslProvider .OPENSSL_REFCNT ;
151
+ boolean ocspEnabled = config .getBoolean (getSslOcspEnabledProperty ());
152
+ TriState tcnativeOcspStapling = config .getTristate (getSslTcnativeOcspStaplingEnabledProperty ());
153
+
154
+ if (tcnative && ocspEnabled && tcnativeOcspStapling .isDefault () && OpenSsl .isOcspSupported ()) {
155
+ // Maintain old behaviour (mostly, we also check for OpenSsl.isOcspSupported())
156
+ builder .enableOcsp (ocspEnabled );
157
+ } else if (tcnativeOcspStapling .isTrue ()) {
158
+ if (!tcnative ) {
159
+ // Don't override the explicit setting, let it error out
160
+ LOG .error ("Trying to enable OpenSSL OCSP stapling for non-OpenSSL TLS provider. "
161
+ + "This is going to fail. Please fix the TLS configuration" );
162
+ } else if (!OpenSsl .isOcspSupported ()) {
163
+ LOG .warn ("Trying to enable OpenSSL OCSP stapling for OpenSSL provider {} which does not support it. "
164
+ + "This is either going to be ignored or fail." , OpenSsl .versionString ());
165
+ }
166
+ builder .enableOcsp (true );
167
+ } else if (tcnativeOcspStapling .isFalse ()) {
168
+ builder .enableOcsp (false );
169
+ }
170
+ return builder ;
171
+ }
172
+
172
173
private SslContext addHostnameVerification (SslContext sslContext , String clientOrServer ) {
173
174
return new DelegatingSslContext (sslContext ) {
174
175
@ Override
0 commit comments