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

svelte-kit preview --https ... ignores custom cert in config.kit.vite.[preview|server].https #5312

Closed
alipi opened this issue Jun 29, 2022 · 0 comments · Fixed by #5332
Closed

Comments

@alipi
Copy link

alipi commented Jun 29, 2022

Describe the bug

The custom cert config in config.kit.vite.[preview|server].https is now ignored by svelte-kit preview --https ....

This patch works, but I don't know if it's the correct fix:

$ cat @sveltejs+kit+1.0.0-next.355.patch
diff --git a/node_modules/@sveltejs/kit/dist/cli.js b/node_modules/@sveltejs/kit/dist/cli.js
index 8b3547b..b868a2e 100644
--- a/node_modules/@sveltejs/kit/dist/cli.js
+++ b/node_modules/@sveltejs/kit/dist/cli.js
@@ -181,7 +181,7 @@ prog
                        // optional config from command-line flags
                        // these should take precedence, but not print conflict warnings
                        if (host) vite_config.preview.host = host;
-                       if (https) vite_config.preview.https = https;
+                       if (https) vite_config.preview.https = vite_config.preview.https || https;
                        if (port) vite_config.preview.port = port;
 
                        const preview_server = await vite.preview(vite_config);

Reproduction

svelte.config.js:

config.kit.vite.preview = {
   https: {
      key: readFileSync(resolve(__dirname, "my-dev.key"), "utf8"),
      cert: readFileSync(resolve(__dirname, "my-dev.crt"), "utf8")
   }
};

run:
$ npx svelte-kit preview --https --host --port 5000

Some internally created cert is returned instead of the one specified in the config.

$ openssl s_client -showcerts -servername localhost -connect localhost:5000 <<< "Q" | openssl x509 -text | grep -iA2 "Validity"
depth=0 CN = example.org, C = US, ST = Virginia, L = Blacksburg, O = Test, OU = Test
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = example.org, C = US, ST = Virginia, L = Blacksburg, O = Test, OU = Test
verify return:1
DONE
        Validity
            Not Before: Jun 29 10:05:25 2022 GMT
            Not After : Jul 29 10:05:25 2022 GMT

Logs

No response

System Info

$ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"

  System:
    OS: Linux 5.10 Generic 36 (Generic) 36 (Generic)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Memory: 14.75 GB / 15.59 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.14.0 - /usr/bin/node
    npm: 8.13.1 - /usr/local/bin/npm

Severity

blocking an upgrade

Additional Information

No response

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

Successfully merging a pull request may close this issue.

1 participant