Skip to content
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

Unable to connect with TLS enabled starting from version 2.4.2 #72

Open
HeikoMueller opened this issue Nov 20, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@HeikoMueller
Copy link

HeikoMueller commented Nov 20, 2023

Describe the bug
A clear and concise description of what the bug is.
I am unable to estabish a TLS connection, neither with .certpath nor .sslContext, starting from version 2.4.2.
Version 2.4.1 works without problems

To Reproduce
Steps to reproduce the behavior:

  1. TODO
  • Create a self-signed certificate on RethinkDB server, add it to client's trust store, then

private SSLContext initializeSSLContext(RethinkSinkConfig config) throws KeyStoreException,NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException {
KeyStore keyStore = loadCertificate(config.getCertpath());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tmf.getTrustManagers(), null);
return sslContext;
}
private KeyStore loadCertificate(String certPath) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null); // Initialize KeyStore

    try (FileInputStream certInputStream = new FileInputStream(certPath)) {
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        X509Certificate caCert = (X509Certificate) cf.generateCertificate(certInputStream);
        keyStore.setCertificateEntry("caCert", caCert);
    } catch (FileNotFoundException e) {
        log.log(Level.SEVERE, "Certificate file not found at " + certPath, e);
        throw e;
    } catch (CertificateException | IOException e) {
        log.log(Level.SEVERE, "Error loading certificate from " + certPath, e);
        throw e;
    }
    return keyStore;

}

SSLContext sslContext = initializeSSLContext(config);
Connection connection = r.connection()
.hostname(config.getHost())
.port(config.getPort())
.db(config.getDb())
.user(config.getUsername(), config.getPassword())
.sslContext(sslContext)
// .certFile(certStream)
.connect();

Expected behavior
A clear and concise description of what you expected to happen.
Java client shall connect. It does not. No exceptions are thrown. Same with .certFile(certStream) option.
Code works as expected up to 2.4.1

System info
RethinkDB Version: 2.4.3
openjdk 17.0.7 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu118.04)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Ubuntu-0ubuntu118.04, mixed mode, sharing)

@HeikoMueller HeikoMueller added the bug Something isn't working label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant