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

[Feature][Zeta] Support enable https protocol for rest-api v2 #8583

Closed
2 of 3 tasks
hailin0 opened this issue Jan 23, 2025 · 13 comments · Fixed by #9010 · May be fixed by #8698
Closed
2 of 3 tasks

[Feature][Zeta] Support enable https protocol for rest-api v2 #8583

hailin0 opened this issue Jan 23, 2025 · 13 comments · Fixed by #9010 · May be fixed by #8698

Comments

@hailin0
Copy link
Member

hailin0 commented Jan 23, 2025

Search before asking

  • I had searched in the feature and found no similar feature requirement.

Description

Currently we support using jetty to provide http api services, but not yet support https protocol, so we can add support for https to enhance security.

Updates


seatunnel:
  engine:
    http:
       ......
      enable-https: true
      https-port: 8443
      keystore: /path/to/file.keystore
      keystore-password: keystore_password
      key-password: key_password

      // optional:Two-way authentication
      truststore: /path/to/file.truststore
      truststore-password: truststore_password
      ......

reference
https://jetty.org/docs/jetty/10/programming-guide/server/http.html#connector-protocol-http11-tls
https://jetty.org/docs/jetty/10/operations-guide/keystore/index.html#client-authn

Usage Scenario

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@liugddx
Copy link
Member

liugddx commented Jan 24, 2025

This is a demo

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import java.io.File;

public class JettyServer {
    public static void main(String[] args) throws Exception {
        Server server = new Server();

        ServerConnector httpConnector = new ServerConnector(server);
        httpConnector.setPort(8080);
        server.addConnector(httpConnector);

        String keystorePath = "/path/to/keystore.jks";
        String keystorePassword = "your_keystore_password";
        String keyManagerPassword = "your_key_password";

        File keystoreFile = new File(keystorePath);
        if (keystoreFile.exists() && keystoreFile.isFile()) {

            SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
            sslContextFactory.setKeyStorePath(keystorePath);
            sslContextFactory.setKeyStorePassword(keystorePassword);
            sslContextFactory.setKeyManagerPassword(keyManagerPassword);

            ServerConnector httpsConnector = new ServerConnector(server, sslContextFactory);
            httpsConnector.setPort(8443);
            server.addConnector(httpsConnector);
        } else {
            System.out.println("No HTTPS configuration detected, falling back to HTTP...");
        }

        server.setHandler(...);

        server.start();
        server.join();
    }
}

@hailin0
Copy link
Member Author

hailin0 commented Jan 24, 2025

This is a demo

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import java.io.File;

public class JettyServer {
    public static void main(String[] args) throws Exception {
        Server server = new Server();

        ServerConnector httpConnector = new ServerConnector(server);
        httpConnector.setPort(8080);
        server.addConnector(httpConnector);

        String keystorePath = "/path/to/keystore.jks";
        String keystorePassword = "your_keystore_password";
        String keyManagerPassword = "your_key_password";

        File keystoreFile = new File(keystorePath);
        if (keystoreFile.exists() && keystoreFile.isFile()) {

            SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
            sslContextFactory.setKeyStorePath(keystorePath);
            sslContextFactory.setKeyStorePassword(keystorePassword);
            sslContextFactory.setKeyManagerPassword(keyManagerPassword);

            ServerConnector httpsConnector = new ServerConnector(server, sslContextFactory);
            httpsConnector.setPort(8443);
            server.addConnector(httpsConnector);
        } else {
            System.out.println("No HTTPS configuration detected, falling back to HTTP...");
        }

        server.setHandler(...);

        server.start();
        server.join();
    }
}

Add

        // optional:Two-way authentication
        if (trustStorePath != null && truststorePassword != null) {
            sslContextFactory.setNeedClientAuth(true);
            sslContextFactory.setTrustStorePath(trustStorePath);
            sslContextFactory.setTrustStorePassword(truststorePassword);
        }

@hailin0 hailin0 changed the title [Feature][Zeta] Support enable https protocol [Feature][Zeta] Support enable https protocol for rest-api v2 Jan 24, 2025
@akulabs8
Copy link
Contributor

Hey I am new to this repo but would like to contribute, so shall I help?

@liugddx
Copy link
Member

liugddx commented Jan 26, 2025

Hey I am new to this repo but would like to contribute, so shall I help?

Sure. Please feel free to let me know if you have any questions.

@akulabs8
Copy link
Contributor

akulabs8 commented Feb 3, 2025

Hey @liugddx @hailin0
I have come up with a draft PR: #8599

With added https support. I am yet to add the test cases and so on but just sharing to be sure if I am moving in the right direction!

P.S. Could you pls assign this ticket to my name?

@liugddx
Copy link
Member

liugddx commented Feb 4, 2025

Hey @liugddx @hailin0 I have come up with a draft PR: #8599

With added https support. I am yet to add the test cases and so on but just sharing to be sure if I am moving in the right direction!

P.S. Could you pls assign this ticket to my name?

Already assigned to you.

@hailin0
Copy link
Member Author

hailin0 commented Feb 13, 2025

hi~ @akulabs8

Is there any progress on this task?

@akulabs8
Copy link
Contributor

@hailin0 yes working on it, by this weekend I will make some good progress...

@akulabs8
Copy link
Contributor

Hey @hailin0 , #8698

Please take a look here, I might need some help with e2e tests as how to deal with certificates

@akulabs8
Copy link
Contributor

Hey , I am new to this Project but my goal is to learn more and be an integral part of the project. Right now I am struggling with the e2e tests and how to handle the keystore and truststore files for the same, so maybe someone else can continue the PR and i can learn and then apply it in some new issues.

@hailin0 hailin0 linked a pull request Feb 18, 2025 that will close this issue
4 tasks
@hailin0
Copy link
Member Author

hailin0 commented Feb 28, 2025

Hey , I am new to this Project but my goal is to learn more and be an integral part of the project. Right now I am struggling with the e2e tests and how to handle the keystore and truststore files for the same, so maybe someone else can continue the PR and i can learn and then apply it in some new issues.

@akulabs8
Sorry I'm late, do you still want to continue this task?

@akulabs8
Copy link
Contributor

akulabs8 commented Mar 1, 2025

@hailin0 currently I won't be able to move it forward!

@hailin0
Copy link
Member Author

hailin0 commented Mar 15, 2025

@akulabs8

Thanks for your contribution. You can close the PR(#8698) and we will assign the issue to other contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment