0

I've generated a self-signed certificate using the following command:

subj="/C=US/ST=Denial/L=Home/O=Student/CN=data.com"


# -nodes flag provides no passphrase entry
openssl req \
  -x509 \
  -nodes \
  -days 365 \
  -newkey rsa:2048 \
  -keyout privateKey.key \
  -out certificate.crt \
  -subj "$subj"

However, I'm not finding any good examples that show how to use the file certificate.crt with an Undertow.io Web server. I'd like to use the certificate to create an SSLContext with which I can then use addHttpsListener from the Undertow api.

I've dug around reading up on TrustManagers and KeyStores, but I haven't been able to find the right steps to add this certificate to the server to then serve Https. What are the right steps to create an Https server with undertow using this self-signed certificate?

Update I intend not to deploy this this with WildFly. It's intended as a an executable jar standing up the server from a 'main' via the command-line. (A bit more complicated than that, but there will be no xml).

lucidquiet
  • 6,124
  • 7
  • 51
  • 88
  • How are you deploying undertow? As part of WildFly? Embedded in your own code? – schtever Jul 17 '15 at 17:45
  • Embedded in my own code. A simple main that sets up the base server. A bit more than the simple example shown. No xml configuration. – lucidquiet Jul 17 '15 at 20:43
  • 2
    Basically duplicate of http://stackoverflow.com/questions/27906682/enabling-https-in-undertow . Note that the server must have the cert **and the (matching) private key**; in general it also needs any chain cert(s) for CA-issued, but your self-signed cert doesn't have any chain. Remember all clients using your server will need to import (or otherwise make trusted) your cert, repeated every time you change. – dave_thompson_085 Jul 18 '15 at 05:56

0 Answers0