Allow Setting SSL Certs via string instead of just File Path #5810
Labels
cli
related to cli/ dir
public API
related to "Deno" namespace in JS
suggestion
suggestions for new features (yet to be agreed)
I'm was trying to find documentation about the HTTPSOptions object that can be passed to the serveTLS and listenAndServeTLS functions. I couldn't find much.
From looking at the code, it seems that it is not possible to specify the cert using a string of the cert itself instead of a file path to the cert file.
For example, let's say I have module call ssl.js that looks like this:
I'd like the ability to
import { certificate, privateKey }
and use those values to set the HTTPSOptions object. You have this flexibility in node's https.createServer function.I realize that the developer was trying to eliminate code by accepting a path instead of the cert's actual string. However, this shortcut removes a little flexibility; if the cert is already cached as a string, another read cannot be avoided. This also make it impossible to run the script without the
--allow-read
permission. If the option accepted the actual string, instead of just the file's path, no read access would be necessary to run the script.This also prevents you from being able to bundle your app into a totally independent, single standalone file; bare minimum you would have to publish 3 files: the bundle.js, the private key, and the public key.
I'm not sure how you'd address this in a manner that doesn't break existing code. If it is too late to make it accept a cert-string instead of file-path, then perhaps, in addition to the certFile and keyFile properties you could also add certString and keyString properties that get checked when certFile and keyFile are undefined.
Lastly, if you can think of other places in Deno, where it assumes that a string is coming from a file, those places too may also be (inadvertently) sacrificing flexibility for convenience.
The text was updated successfully, but these errors were encountered: