-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement a mechanism to skip SSL verification #4083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1c78117
5800013
c4273e5
2030489
86ee3fc
2433c5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.provectus.kafka.ui.util; | ||
|
||
import com.provectus.kafka.ui.config.ClustersProperties; | ||
import java.util.Properties; | ||
import javax.annotation.Nullable; | ||
import org.apache.kafka.common.config.SslConfigs; | ||
|
||
public final class KafkaClientSslPropertiesUtil { | ||
|
||
private KafkaClientSslPropertiesUtil() { | ||
} | ||
|
||
public static void addKafkaSslProperties(@Nullable ClustersProperties.TruststoreConfig truststoreConfig, | ||
Properties sink) { | ||
if (truststoreConfig == null) { | ||
return; | ||
} | ||
|
||
if (truststoreConfig.getTruststoreLocation() == null) { | ||
return; | ||
} | ||
Comment on lines
+19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if |
||
|
||
sink.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, truststoreConfig.getTruststoreLocation()); | ||
|
||
if (truststoreConfig.getTruststorePassword() != null) { | ||
sink.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, truststoreConfig.getTruststorePassword()); | ||
} | ||
|
||
if (!truststoreConfig.isVerifySsl()) { | ||
sink.put(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, ""); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import com.provectus.kafka.ui.exception.ValidationException; | ||
import io.netty.handler.ssl.SslContext; | ||
import io.netty.handler.ssl.SslContextBuilder; | ||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory; | ||
import java.io.FileInputStream; | ||
import java.security.KeyStore; | ||
import java.util.function.Consumer; | ||
|
@@ -45,6 +46,10 @@ private static ObjectMapper defaultOM() { | |
|
||
public WebClientConfigurator configureSsl(@Nullable ClustersProperties.TruststoreConfig truststoreConfig, | ||
@Nullable ClustersProperties.KeystoreConfig keystoreConfig) { | ||
if (truststoreConfig != null && !truststoreConfig.isVerifySsl()) { | ||
return configureNoSsl(); | ||
} | ||
|
||
return configureSsl( | ||
keystoreConfig != null ? keystoreConfig.getKeystoreLocation() : null, | ||
keystoreConfig != null ? keystoreConfig.getKeystorePassword() : null, | ||
|
@@ -97,6 +102,17 @@ private WebClientConfigurator configureSsl( | |
return this; | ||
} | ||
|
||
@SneakyThrows | ||
public WebClientConfigurator configureNoSsl() { | ||
var contextBuilder = SslContextBuilder.forClient(); | ||
contextBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE); | ||
|
||
SslContext context = contextBuilder.build(); | ||
|
||
httpClient = httpClient.secure(t -> t.sslContext(context)); | ||
return this; | ||
} | ||
Comment on lines
+105
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls simplify |
||
|
||
public WebClientConfigurator configureBasicAuth(@Nullable String username, @Nullable String password) { | ||
if (username != null && password != null) { | ||
builder.defaultHeaders(httpHeaders -> httpHeaders.setBasicAuth(username, password)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ rbac: | |
actions: all | ||
|
||
- resource: connect | ||
value: "*" | ||
value: ".*" | ||
actions: all | ||
|
||
- resource: ksql | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to add property to kafka-ui-api.yaml