Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 640273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:56:07+00:00 2026-05-13T20:56:07+00:00

I need to set up a really lightweight HTTPS server for a Java application.

  • 0

I need to set up a really lightweight HTTPS server for a Java application. It’s a simulator that’s being used in our development labs to simulate the HTTPS connections accepted by a piece of equipment in the wild. Because it’s purely a lightweight development tool and isn’t used in production in any way at all, I’m quite happy to bypass certifications and as much negotiation as I can.

I’m planning on using the HttpsServer class in Java 6 SE but I’m struggling to get it working. As a test client, I’m using wget from the cygwin command line (wget https://[address]:[port]) but wget reports that it was “Unable to establish SSL connection”.

If I run wget with the -d option for debugging it tells me “SSL handshake failed”.

I’ve spent 30 minutes googling this and everything seems to just point back to the fairly useless Java 6 documentation that describes the methods but doesn’t actually talk about how to get the darn thing talking or provide any example code at all.

Can anyone nudge me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:56:07+00:00Added an answer on May 13, 2026 at 8:56 pm

    What I eventually used was this:

    try {
        // Set up the socket address
        InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), config.getHttpsPort());
    
        // Initialise the HTTPS server
        HttpsServer httpsServer = HttpsServer.create(address, 0);
        SSLContext sslContext = SSLContext.getInstance("TLS");
    
        // Initialise the keystore
        char[] password = "simulator".toCharArray();
        KeyStore ks = KeyStore.getInstance("JKS");
        FileInputStream fis = new FileInputStream("lig.keystore");
        ks.load(fis, password);
    
        // Set up the key manager factory
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
        kmf.init(ks, password);
    
        // Set up the trust manager factory
        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
        tmf.init(ks);
    
        // Set up the HTTPS context and parameters
        sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
        httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext) {
            public void configure(HttpsParameters params) {
                try {
                    // Initialise the SSL context
                    SSLContext c = SSLContext.getDefault();
                    SSLEngine engine = c.createSSLEngine();
                    params.setNeedClientAuth(false);
                    params.setCipherSuites(engine.getEnabledCipherSuites());
                    params.setProtocols(engine.getEnabledProtocols());
    
                    // Get the default parameters
                    SSLParameters defaultSSLParameters = c.getDefaultSSLParameters();
                    params.setSSLParameters(defaultSSLParameters);
                } catch (Exception ex) {
                    ILogger log = new LoggerFactory().getLogger();
                    log.exception(ex);
                    log.error("Failed to create HTTPS port");
                }
            }
        });
        LigServer server = new LigServer(httpsServer);
        joinableThreadList.add(server.getJoinableThread());
    } catch (Exception exception) {
        log.exception(exception);
        log.error("Failed to create HTTPS server on port " + config.getHttpsPort() + " of localhost");
    }
    

    To generate a keystore:

    $ keytool -genkeypair -keyalg RSA -alias self_signed -keypass simulator \
      -keystore lig.keystore -storepass simulator
    

    See also here.

    Potentially storepass and keypass might be different, in which case the ks.load and kmf.init must use storepass and keypass, respectively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set up a server that will accept some text from my
I need to set up a django development environment that is publicly viewable on
I need to set the default icon that VS uses for the project to
I need to set up an <input type=text /> so that it will accept
I have a need to set a collection of name/value pairs inside my application
I have a set of really big images out of which I need to
we are using django to develop a customer-management application, and we need to set
iPhone OS Development I need to set the names of UITableView cells to strings
For a new project that I'm working on I need to set up a
I need to set a website that is editable so I think that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.