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 setup SSL #127

Open
UjCbFwtBayFM opened this issue Jan 25, 2022 · 2 comments
Open

Unable to setup SSL #127

UjCbFwtBayFM opened this issue Jan 25, 2022 · 2 comments

Comments

@UjCbFwtBayFM
Copy link

Using Windows 10 19041.1415 (2004) with TiddlyServer 2.1.4 and OpenSSL 1.1.1m.
Followed instructions in documentation and https.js to create keys.
Command
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout tiddlyserver.key -out tiddlyserver.cer
works but
openssl req -x509 -out localhost.cer -keyout localhost.key -days 365 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
fails with error "specified file cannot be found".

@marksweston
Copy link

I am also trying to do this.

The documentation refers to https.js but I've never been able to find it. Where is it?

@Arlen22
Copy link
Owner

Arlen22 commented Mar 20, 2022

Those instructions are old, I guess. The current docs are "read the source" for that, unfortunately. In short, you set config.bindInfo.https to a JS file relative to the settings file (as shown below), and export the function serverOptions (as shown second).

"bindInfo": {
    "https": "./relative to this file.js",
  },

Refer to the NodeJS documentation for the available options. The options object is passed directly into the https.createServer call.

The host argument is the same that gets passed to the server.listen function ( this.server.listen(port, host); )

// using example object from nodejs docs
exports.serverOptions: = (host) => { 
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

The object is literally passed directly into the createServer call as shown below (in pseudo code).

var serverOptions = require("/resolved/path/to/https.js").serverOptions;
foreach (var host in hosts) https.createServer(serverOptions(host));

If more than one listener gets created it will be called for each listener, so keep that in mind.

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

No branches or pull requests

3 participants