GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HttpsConfigurator.configure method not executed for https connections · Issue #15 · robaho/httpserver

HttpsConfigurator.configure method not executed for https connections #15

New issue
Copy link
New issue
Copy link
Closed
Closed
HttpsConfigurator.configure method not executed for https connections#15
Copy link

Description

@viretp
viretp
opened on Jan 16, 2025
Issue body actions

We are trying to update from jdk httpserver to robaho httpserver and are experiencing following problem:
The HttpsConfigurator.configure method does not seem to get called when starting a new https connection.
We need the configure in order to be able to set up diverses SSL settings, f.i. setWantClientAuth(true) on the SSLParams, to get a client certificate from the remote connection.

I have searched through the robaho code but I could not figure out where the configure method is getting called.
In the jdk httpserver implementation this is performed in ServerImpl.Exchange.run() when creating the new SSLStream instance (the call is in the SSLStream constructor).

This means that using the same code we cannot replace the jdk httpserver with robaho httpserver, and we cannot even figure out how to change our code in order to have the configure method called.

Version used: 1.0.19

Thanks in advance for any help.

Activity

  1. robaho
    added a commit that references this issue on Jan 16, 2025

    fix issue #15 HttpsConfigurator.configure method not executed for htt…

    4d2c7b6
  2. robaho commented on Jan 16, 2025

    @robaho
    robaho
    on Jan 16, 2025
    Owner
    More actions

    This is fixed in version 1.0.20 that is being pushed to maven now. Sorry about that - strangely, it doesn't appear that the JDK has any tests surrounding this. All of the current tests pass. I am fairly certain it is fixed correctly - feel free to reopen if it isn't.

  3. robaho
    closed this as completedon Jan 16, 2025
  4. robaho commented on Jan 16, 2025

    @robaho
    robaho
    on Jan 16, 2025
    Owner
    More actions

    @viretp do you think you might be able to attach a minimal usage in your case so I can create a test case?

  5. SentryMan commented on Jan 16, 2025

    @SentryMan
    SentryMan
    on Jan 16, 2025
    Contributor
    More actions

    I was able to replicate it by creating a keystore using

    keytool -genkey -keyalg RSA -alias selfsigned -keystore sus.jks -storepass password -validity 360 -keysize 2048
    

    and using it in the code with

        char[] passphrase = "password".toCharArray();
    
        KeyStore ks = KeyStore.getInstance("JKS");
    
        var path =
            Path.of("sus.jks").toAbsolutePath();
        ks.load(Files.newInputStream(path), passphrase);
    
        // Set up the key manager factory
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
        kmf.init(ks, passphrase);
    
        // Set up the trust manager factory
        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
        tmf.init(ks);
    
        // Set up the SSL context
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
    
        // Create Server
        HttpsConfigurator https =
            new HttpsConfigurator(sslContext) {
              @Override
              public void configure(HttpsParameters params) {
                //didn't get here
                System.out.println("Here");
              }
            };
    
        var httpsServer = HttpsServer.create(new InetSocketAddress(8443), 0);
        httpsServer.setHttpsConfigurator(https);
    
        httpsServer.createContext(
            "/",
            exchange -> {
              var str = "sus".getBytes();
              exchange.sendResponseHeaders(200, str.length);
              exchange.getResponseBody().write(str);
            });
  6. robaho commented on Jan 17, 2025

    @robaho
    robaho
    on Jan 17, 2025
    Owner
    More actions

    I am re-opening this, the code changes seem to have broken https.

  7. robaho
    reopened this on Jan 17, 2025
  8. robaho
    added a commit that references this issue on Jan 17, 2025

    test case for issue #15 HttpsConfigurator.configure method not execut…

    8890561
  9. robaho commented on Jan 17, 2025

    @robaho
    robaho
    on Jan 17, 2025
    Owner
    More actions

    false alarm. The code changes work as expected, added test case HttpsConfiguratorTest.

  10. robaho
    closed this as completedon Jan 17, 2025
  11. viretp commented on Jan 17, 2025

    @viretp
    viretp
    on Jan 17, 2025
    ContributorAuthor
    More actions

    That was really fast! I have tested the new version 1.0.20 and the problem is gone.
    Great job: thank you very much.

  12. robaho commented on Jan 17, 2025

    @robaho
    robaho
    on Jan 17, 2025
    Owner
    More actions

    @viretp glad I was able to fix it quickly. Thanks @SentryMan for the assist.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.