Hello Everyone, How do we place SSL configs to con...
# troubleshooting
m
Hello Everyone, How do we place SSL configs to connect opensearch cluster using flink-opensearch-connector? we have a flink job which consuming data from kafka and streams data to the opensearch index. We have used flink version 1.17.1 and opensearch-connector version 1.0.1-1.17. The following code snippet used for pushing data to opensearch index with setAllowInsecure(true) but when we set setAllowInsecure(false) it is looking for SSL certs related to opensearch. (Error: Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alert.createSSLException(Unknown Source) ~[?:?])
Copy code
stream.sinkTo(
                new OpensearchSinkBuilderOrderDetails()
                        .setBulkFlushMaxActions(1)
                        .setHosts(new HttpHost("hostname1", 9200, "https"),
                                new HttpHost("hostname2", 9200, "https"))
                        .setConnectionUsername("OPEN_SEARCH_USERNAME")
                        .setConnectionPassword("OPEN_SEARCH_PASSWORD")
                        .setEmitter(
                                (element, context, indexer) ->
                                        indexer.add(createIndexRequest(element)))
						.setAllowInsecure(true)				
                        .build());
Thanks in advance.
t
When you switch setAllowInsecure(false), it’s essentially Flink’s way of saying, “Alright, let’s make this connection secure,” and it starts looking for those SSL certificates to establish a trusted connection. The error you’re seeing is a classic case of the Java environment not being able to find or trust the certificate chain of the OpenSearch server.
To resolve this, you need to ensure that the SSL certificates of your OpenSearch cluster are properly imported into the Java TrustStore used by your Flink job. Here’s a simplified approach to how you can do this: a. Obtain the SSL Certificate: First off, you need the certificate from your OpenSearch cluster. If you don’t already have it, you might need to export it from the cluster or get it from whoever manages your OpenSearch cluster. b. Import the Certificate into a TrustStore: • You can use the Java keytool to import the certificate. The command might look something like this: keytool -import -alias opensearchCert -file path/to/your/opensearch/certificate.pem -keystore path/to/your/truststore.jks -storepass your-keystore-password 1. • Make sure to replace path/to/your/opensearch/certificate.pem with the actual path to your OpenSearch certificate and path/to/your/truststore.jks with where you want your TrustStore to be. Also, your-keystore-password should be replaced with a secure password of your choosing. a. Configure Flink to Use the TrustStore: • Once the certificate is in your TrustStore, you need to tell your Flink job to use this TrustStore. This is typically done by setting JVM parameters. If you’re running your Flink job from a command line or a script, you can set these parameters: -Djavax.net.ssl.trustStore=path/to/your/truststore.jks -Djavax.net.ssl.trustStorePassword=your-keystore-password 1. • If you’re running your job in a containerized or orchestrated environment (like Kubernetes), you’ll need to set these as environment variables or configuration parameters, depending on your setup. Remember, the path to the TrustStore and the password should match what you used when importing the certificate. This process ensures that when your Flink job tries to connect to your OpenSearch cluster with SSL, it can trust the cluster’s certificate, thereby avoiding the SSL handshake error. Let’s give it a whirl, and if the SSL specter decides to rear its head again, we’ll show it who’s boss with some good old-fashioned troubleshooting!
Best guess